Revision 45011 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/TestGrammarCompiler.java
TestGrammarCompiler.java | ||
---|---|---|
296 | 296 |
|
297 | 297 |
Code code = compiler.compileExpression(source); |
298 | 298 |
link(code); |
299 |
assertEquals("CREATE_FUNCTION('test1', LIST('nombre'), print(('Hola ' + \"nombre\")), NULL, NULL, NULL)", code.toString());
|
|
299 |
assertEquals("CREATE_FUNCTION('test1', [ 'nombre' ], print(('Hola ' + \"nombre\")), NULL, NULL, NULL)", code.toString());
|
|
300 | 300 |
} |
301 | 301 |
|
302 | 302 |
public void testDef3() { |
... | ... | |
306 | 306 |
|
307 | 307 |
Code code = compiler.compileExpression(source); |
308 | 308 |
link(code); |
309 |
assertEquals("CREATE_FUNCTION('test1', LIST('nombre'), RETURN(('Hola ' || \"nombre\")), NULL, NULL, NULL)", code.toString());
|
|
309 |
assertEquals("CREATE_FUNCTION('test1', [ 'nombre' ], RETURN(('Hola ' || \"nombre\")), NULL, NULL, NULL)", code.toString());
|
|
310 | 310 |
} |
311 | 311 |
|
312 | 312 |
public void testCreateFunctionExtern1() { |
... | ... | |
316 | 316 |
|
317 | 317 |
Code code = compiler.compileExpression(source); |
318 | 318 |
link(code); |
319 |
assertEquals("CREATE_FUNCTION('test1', LIST('nombre'), NULL, 'addons/test/test', 'test1', 'cosa')", code.toString());
|
|
319 |
assertEquals("CREATE_FUNCTION('test1', [ 'nombre' ], NULL, 'addons/test/test', 'test1', 'cosa')", code.toString());
|
|
320 | 320 |
} |
321 | 321 |
|
322 | 322 |
public void testList() { |
323 |
String source = "set x TO [ 'hola','adios','fin' ]"; |
|
324 |
|
|
325 |
Compiler compiler = createCompiler(); |
|
326 |
|
|
327 |
Code code = compiler.compileExpression(source); |
|
328 |
link(code); |
|
329 |
assertEquals("LET('x', [ 'hola', 'adios', 'fin' ])", code.toString()); |
|
330 |
} |
|
331 |
|
|
332 |
public void testList2() { |
|
323 | 333 |
String source = "set x TO LIST('hola','adios','fin')"; |
324 | 334 |
|
325 | 335 |
Compiler compiler = createCompiler(); |
326 | 336 |
|
327 | 337 |
Code code = compiler.compileExpression(source); |
328 | 338 |
link(code); |
329 |
assertEquals("LET('x', LIST('hola', 'adios', 'fin'))", code.toString());
|
|
339 |
assertEquals("LET('x', [ 'hola', 'adios', 'fin' ])", code.toString());
|
|
330 | 340 |
} |
331 | 341 |
|
332 | 342 |
public void testTuple() { |
... | ... | |
356 | 366 |
|
357 | 367 |
Code code = compiler.compileExpression(source); |
358 | 368 |
link(code); |
359 |
assertEquals("BLOCK(LET('x', ''), FOREACH('n', list('hola', 'adios', 'fin'), LET('x', ((\"x\" || ' ') || \"n\"))))", code.toString());
|
|
369 |
assertEquals("BLOCK(LET('x', ''), FOREACH('n', [ 'hola', 'adios', 'fin' ], LET('x', ((\"x\" || ' ') || \"n\"))))", code.toString());
|
|
360 | 370 |
} |
361 | 371 |
|
362 | 372 |
public void testUseCase2() { |
363 |
String source = "begin set s = ''; set x = LIST('hola','adios','fin'); FOR n in RANGE(3): set s = s || ' ' || x[n]; end for; end";
|
|
373 |
String source = "begin set s = ''; set x = [ 'hola','adios','fin' ]; FOR n in RANGE(3): set s = s || ' ' || x[n]; end for; end";
|
|
364 | 374 |
|
365 | 375 |
Compiler compiler = createCompiler(); |
366 | 376 |
|
367 | 377 |
Code code = compiler.compileExpression(source); |
368 | 378 |
link(code); |
369 |
assertEquals("BLOCK(LET('s', ''), LET('x', LIST('hola', 'adios', 'fin')), FOREACH('n', RANGE(3), LET('s', ((\"s\" || ' ') || GETITEM(\"x\", \"n\")))))", code.toString());
|
|
379 |
assertEquals("BLOCK(LET('s', ''), LET('x', [ 'hola', 'adios', 'fin' ]), FOREACH('n', RANGE(3), LET('s', ((\"s\" || ' ') || \"x\"[\"n\"]))))", code.toString());
|
|
370 | 380 |
} |
371 | 381 |
|
372 | 382 |
|
Also available in: Unified diff