equal
deleted
inserted
replaced
178 output := '' writeStream. |
178 output := '' writeStream. |
179 self withTranscriptRedirectedTo:output do:aBlock. |
179 self withTranscriptRedirectedTo:output do:aBlock. |
180 ^ output contents |
180 ^ output contents |
181 ! |
181 ! |
182 |
182 |
|
183 shouldRaiseParseError:aString |
|
184 self |
|
185 should:[ |
|
186 JavaScriptParser parseExpression:aString |
|
187 ] |
|
188 raise:ParseError |
|
189 ! |
|
190 |
183 withTranscriptRedirectedTo:aStream do:aBlock |
191 withTranscriptRedirectedTo:aStream do:aBlock |
184 "yes, globals are bad - that's what we need stuff like this for..." |
192 "yes, globals are bad - that's what we need stuff like this for..." |
185 |
193 |
186 |savedTranscript| |
194 |savedTranscript| |
187 |
195 |
4804 ! |
4812 ! |
4805 |
4813 |
4806 testRegex01 |
4814 testRegex01 |
4807 |rslt| |
4815 |rslt| |
4808 |
4816 |
4809 self skipIf:true description:'skipped until regexes are implemented'. |
|
4810 rslt := JavaScriptParser evaluate:'var pat = /foo/i;'. |
4817 rslt := JavaScriptParser evaluate:'var pat = /foo/i;'. |
4811 self assert:(rslt isKindOf:Regex::RxsRegex). |
4818 self assert:(rslt isKindOf:Regex::RxsRegex). |
4812 |
|
4813 |
4819 |
4814 " |
4820 " |
4815 self run:#testRegex01 |
4821 self run:#testRegex01 |
4816 self new testRegex01 |
4822 self new testRegex01 |
4817 " |
4823 " |
6808 |
6814 |
6809 |spec| |
6815 |spec| |
6810 |
6816 |
6811 spec := #( |
6817 spec := #( |
6812 ('#''abc''' #isSymbol (#eval '#abc ') ) |
6818 ('#''abc''' #isSymbol (#eval '#abc ') ) |
|
6819 ('$''a''' #isCharacter (#eval '$a ') ) |
6813 ). |
6820 ). |
6814 |
6821 |
6815 self doTestEachFromSpec:spec. |
6822 self doTestEachFromSpec:spec. |
6816 |
6823 |
6817 " |
6824 " |
6818 self run:#test_42_parse_literals4 |
6825 self run:#test_42_parse_literals4 |
6819 self new test_42_parse_literals4 |
6826 self new test_42_parse_literals4 |
|
6827 " |
|
6828 |
|
6829 "Created: / 09-06-2019 / 17:02:32 / Claus Gittinger" |
|
6830 ! |
|
6831 |
|
6832 test_50_parse_ommitedSemicolons |
|
6833 "we don't do full semicolon insertion (eg. at line breaks); |
|
6834 only a subset is allowed: |
|
6835 before a closing brace '}' |
|
6836 before an else |
|
6837 before the while of a do..while statement" |
|
6838 |
|
6839 JavaScriptParser parseFunction: |
|
6840 'f(arg) { |
|
6841 if (arg) { |
|
6842 print("bla") |
|
6843 } else { |
|
6844 print("blabla") |
|
6845 } |
|
6846 }'. |
|
6847 |
|
6848 JavaScriptParser parseFunction: |
|
6849 'f(arg) { |
|
6850 if (arg) |
|
6851 print("bla") |
|
6852 else { |
|
6853 print("blabla") |
|
6854 } |
|
6855 }'. |
|
6856 |
|
6857 JavaScriptParser parseFunction: |
|
6858 'f(arg) { |
|
6859 do |
|
6860 print("bla") |
|
6861 while (arg) |
|
6862 }'. |
|
6863 |
|
6864 JavaScriptParser parseFunction: |
|
6865 'f(arg) { |
|
6866 return 10 |
|
6867 }'. |
|
6868 |
|
6869 "Created: / 17-11-2014 / 13:28:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
6870 ! |
|
6871 |
|
6872 test_90_parse_shouldReportErrors |
|
6873 self shouldRaiseParseError:' $''ab'' '. "/ only one character in char-literal |
|
6874 |
|
6875 " |
|
6876 self run:#test_90_parse_shouldReportErrors |
|
6877 self new test_90_parse_shouldReportErrors |
6820 " |
6878 " |
6821 |
6879 |
6822 "Created: / 09-06-2019 / 17:02:32 / Claus Gittinger" |
6880 "Created: / 09-06-2019 / 17:02:32 / Claus Gittinger" |
6823 ! |
6881 ! |
6824 |
6882 |
7050 '/* ignored */= ' $= |
7108 '/* ignored */= ' $= |
7051 '/* ignored */ = ' $= |
7109 '/* ignored */ = ' $= |
7052 ' + ' $+ |
7110 ' + ' $+ |
7053 ' - ' $- |
7111 ' - ' $- |
7054 ' * ' $* |
7112 ' * ' $* |
7055 ' / ' $/ |
7113 "/ ' / ' $/ |
7056 ' % ' $% |
7114 ' % ' $% |
7057 ' & ' $& |
7115 ' & ' $& |
7058 ' ^ ' $^ |
7116 ' ^ ' $^ |
7059 ' | ' $| |
7117 ' | ' $| |
7060 ' !! ' $!! |
7118 ' !! ' $!! |
7074 ' **' #'**' |
7132 ' **' #'**' |
7075 |
7133 |
7076 ' += ' #'+=' |
7134 ' += ' #'+=' |
7077 ' -= ' #'-=' |
7135 ' -= ' #'-=' |
7078 ' *= ' #'*=' |
7136 ' *= ' #'*=' |
7079 ' /= ' #'/=' |
7137 "/ ' /= ' #'/=' |
7080 ' %= ' #'%=' |
7138 ' %= ' #'%=' |
7081 ' &= ' #'&=' |
7139 ' &= ' #'&=' |
7082 ' ^= ' #'^=' |
7140 ' ^= ' #'^=' |
7083 ' |= ' #'|=' |
7141 ' |= ' #'|=' |
7084 |
7142 |
7097 ' 1E+10 ' #Float |
7155 ' 1E+10 ' #Float |
7098 ' 1E-10 ' #Float |
7156 ' 1E-10 ' #Float |
7099 ' 1.0d ' #Float |
7157 ' 1.0d ' #Float |
7100 ' 1. ' #Float |
7158 ' 1. ' #Float |
7101 "/ ' 1.' #Float |
7159 "/ ' 1.' #Float |
|
7160 ' "hello" ' #String |
|
7161 ' /hello/ ' #Regex |
7102 ) pairWiseDo:[:src :expectedToken | |
7162 ) pairWiseDo:[:src :expectedToken | |
7103 |scannedToken| |
7163 |scannedToken| |
7104 |
7164 |
7105 scannedToken := (JavaScriptScanner for:src) nextToken. |
7165 scannedToken := (JavaScriptScanner for:src) nextToken. |
7106 self assert:(scannedToken == expectedToken) message:'expected: ',expectedToken, ' got: ',scannedToken. |
7166 self assert:(scannedToken == expectedToken) message:'expected: ',expectedToken, ' got: ',scannedToken. |