Revision 43983 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCompiler.java
TestCompiler.java | ||
---|---|---|
6 | 6 |
import org.gvsig.expressionevaluator.LexicalAnalyzer; |
7 | 7 |
import org.gvsig.expressionevaluator.Compiler; |
8 | 8 |
import org.gvsig.expressionevaluator.Code; |
9 |
import org.gvsig.expressionevaluator.ExpressionSyntaxException; |
|
9 | 10 |
import org.gvsig.expressionevaluator.impl.ExpressionEvaluatorImplLibrary; |
10 | 11 |
|
11 | 12 |
|
... | ... | |
235 | 236 |
|
236 | 237 |
|
237 | 238 |
public void testInvokeMethod2() { |
238 |
String source = "'hola'.indexOf('l')"; |
|
239 |
String source = "'hola'.indexOf('l') ";
|
|
239 | 240 |
|
240 | 241 |
Compiler compiler = createCompiler(); |
241 | 242 |
|
242 | 243 |
Code code = compiler.compileExpression(source); |
243 | 244 |
assertEquals("'hola'->indexOf('l')", code.toString()); |
244 | 245 |
} |
245 |
|
|
246 |
|
|
247 |
public void testSyntaxError1() { |
|
248 |
Compiler compiler = createCompiler(); |
|
249 |
String source; |
|
250 |
|
|
251 |
source = "3 + (2*)"; |
|
252 |
try { |
|
253 |
compiler.compileExpression(source); |
|
254 |
assertTrue("A syntax exception should have been thrown compiling '"+source+"'.", false); |
|
255 |
} catch(ExpressionSyntaxException ex) { |
|
256 |
// Ok |
|
257 |
} |
|
258 |
source = "3 + 2*"; |
|
259 |
try { |
|
260 |
compiler.compileExpression(source); |
|
261 |
assertTrue("A syntax exception should have been thrown compiling '"+source+"'.", false); |
|
262 |
} catch(ExpressionSyntaxException ex) { |
|
263 |
// Ok |
|
264 |
} |
|
265 |
source = "3 + (2*2))"; |
|
266 |
try { |
|
267 |
compiler.compileExpression(source); |
|
268 |
assertTrue("A syntax exception should have been thrown compiling '"+source+"'.", false); |
|
269 |
} catch(ExpressionSyntaxException ex) { |
|
270 |
// Ok |
|
271 |
} |
|
272 |
source = "3 and or 2"; |
|
273 |
try { |
|
274 |
compiler.compileExpression(source); |
|
275 |
assertTrue("A syntax exception should have been thrown compiling '"+source+"'.", false); |
|
276 |
} catch(ExpressionSyntaxException ex) { |
|
277 |
// Ok |
|
278 |
} |
|
279 |
source = "3*/2"; |
|
280 |
try { |
|
281 |
compiler.compileExpression(source); |
|
282 |
assertTrue("A syntax exception should have been thrown compiling '"+source+"'.", false); |
|
283 |
} catch(ExpressionSyntaxException ex) { |
|
284 |
// Ok |
|
285 |
} |
|
286 |
} |
|
246 | 287 |
} |
Also available in: Unified diff