Revision 45153 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', [ 'nombre' ], print(('Hola ' + \"nombre\")), NULL, NULL, NULL)", code.toString()); |
|
299 |
assertEquals("CREATE_FUNCTION('test1', ARRAY[ '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', [ 'nombre' ], RETURN(('Hola ' || \"nombre\")), NULL, NULL, NULL)", code.toString()); |
|
309 |
assertEquals("CREATE_FUNCTION('test1', ARRAY[ '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', [ 'nombre' ], NULL, 'addons/test/test', 'test1', 'cosa')", code.toString()); |
|
319 |
assertEquals("CREATE_FUNCTION('test1', ARRAY[ 'nombre' ], NULL, 'addons/test/test', 'test1', 'cosa')", code.toString());
|
|
320 | 320 |
} |
321 | 321 |
|
322 | 322 |
public void testList() { |
... | ... | |
326 | 326 |
|
327 | 327 |
Code code = compiler.compileExpression(source); |
328 | 328 |
link(code); |
329 |
assertEquals("LET('x', [ 'hola', 'adios', 'fin' ])", code.toString()); |
|
329 |
assertEquals("LET('x', ARRAY[ 'hola', 'adios', 'fin' ])", code.toString());
|
|
330 | 330 |
} |
331 | 331 |
|
332 | 332 |
public void testList2() { |
... | ... | |
336 | 336 |
|
337 | 337 |
Code code = compiler.compileExpression(source); |
338 | 338 |
link(code); |
339 |
assertEquals("LET('x', [ 'hola', 'adios', 'fin' ])", code.toString()); |
|
339 |
assertEquals("LET('x', ARRAY[ 'hola', 'adios', 'fin' ])", code.toString());
|
|
340 | 340 |
} |
341 | 341 |
|
342 | 342 |
public void testTuple() { |
... | ... | |
350 | 350 |
} |
351 | 351 |
|
352 | 352 |
public void testArray() { |
353 |
String source = "set x TO ARRAY('hola','adios','fin')";
|
|
353 |
String source = "set x TO ARRAY['hola','adios','fin']";
|
|
354 | 354 |
|
355 | 355 |
Compiler compiler = createCompiler(); |
356 | 356 |
|
357 | 357 |
Code code = compiler.compileExpression(source); |
358 | 358 |
link(code); |
359 |
assertEquals("LET('x', ARRAY('hola', 'adios', 'fin'))", code.toString());
|
|
359 |
assertEquals("LET('x', ARRAY[ 'hola', 'adios', 'fin' ])", code.toString());
|
|
360 | 360 |
} |
361 | 361 |
|
362 | 362 |
public void testUseCase1() { |
363 |
String source = "begin set x = ''; for n in list('hola','adios','fin'): let x = x || ' ' || n; end for; end";
|
|
363 |
String source = "begin set x = ''; for n in ARRAY['hola','adios','fin']: let x = x || ' ' || n; end for; end";
|
|
364 | 364 |
|
365 | 365 |
Compiler compiler = createCompiler(); |
366 | 366 |
|
367 | 367 |
Code code = compiler.compileExpression(source); |
368 | 368 |
link(code); |
369 |
assertEquals("BLOCK(LET('x', ''), FOREACH('n', [ 'hola', 'adios', 'fin' ], LET('x', ((\"x\" || ' ') || \"n\"))))", code.toString()); |
|
369 |
assertEquals("BLOCK(LET('x', ''), FOREACH('n', ARRAY[ 'hola', 'adios', 'fin' ], LET('x', ((\"x\" || ' ') || \"n\"))))", code.toString());
|
|
370 | 370 |
} |
371 | 371 |
|
372 | 372 |
public void testUseCase2() { |
373 |
String source = "begin set s = ''; set x = [ 'hola','adios','fin' ]; FOR n in RANGE(3): set s = s || ' ' || x[n]; end for; end"; |
|
373 |
String source = "begin set s = ''; set x = ARRAY[ 'hola','adios','fin' ]; FOR n in RANGE(3): set s = s || ' ' || x[n]; end for; end";
|
|
374 | 374 |
|
375 | 375 |
Compiler compiler = createCompiler(); |
376 | 376 |
|
377 | 377 |
Code code = compiler.compileExpression(source); |
378 | 378 |
link(code); |
379 |
assertEquals("BLOCK(LET('s', ''), LET('x', [ 'hola', 'adios', 'fin' ]), FOREACH('n', RANGE(3), LET('s', ((\"s\" || ' ') || \"x\"[\"n\"]))))", code.toString()); |
|
379 |
assertEquals("BLOCK(LET('s', ''), LET('x', ARRAY[ 'hola', 'adios', 'fin' ]), FOREACH('n', RANGE(3), LET('s', ((\"s\" || ' ') || \"x\"[\"n\"]))))", code.toString());
|
|
380 | 380 |
} |
381 | 381 |
|
382 | 382 |
|
Also available in: Unified diff