Revision 46960 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/test/java/org/gvsig/expressionevaluator/TestGrammarCompiler.java
TestGrammarCompiler.java | ||
---|---|---|
154 | 154 |
source.append("BEGIN "); |
155 | 155 |
source.append(" SET X = 0; "); |
156 | 156 |
source.append(" FOR row in (SELECT * FROM countries;) "); // Con ; |
157 |
source.append(" BEGIN ");
|
|
157 |
source.append(" LOOP ");
|
|
158 | 158 |
source.append(" IF row.LASTCENSUS > 0 THEN "); |
159 | 159 |
source.append(" SET X = X + row.LASTCENSUS "); |
160 | 160 |
source.append(" END IF "); |
161 |
source.append(" END FOR ");
|
|
161 |
source.append(" END LOOP ");
|
|
162 | 162 |
source.append("END"); |
163 | 163 |
|
164 | 164 |
Compiler compiler = createCompiler(); |
... | ... | |
173 | 173 |
source.append("BEGIN "); |
174 | 174 |
source.append(" SET X = 0; "); |
175 | 175 |
source.append(" FOR row in (SELECT * FROM countries) "); // Sin ; |
176 |
source.append(" BEGIN ");
|
|
176 |
source.append(" LOOP ");
|
|
177 | 177 |
source.append(" IF row.LASTCENSUS > 0 THEN "); |
178 | 178 |
source.append(" SET X = X + row.LASTCENSUS "); |
179 | 179 |
source.append(" END IF "); |
180 |
source.append(" END FOR ");
|
|
180 |
source.append(" END LOOP ");
|
|
181 | 181 |
source.append("END"); |
182 | 182 |
|
183 | 183 |
Compiler compiler = createCompiler(); |
... | ... | |
187 | 187 |
checkEquals("testSelect3", "BLOCK(LET('X', 0), FOREACH('row', SELECT(TUPLE(), \"countries\", NULL, TUPLE(), TUPLE(), NULL), IF((\"row\".\"LASTCENSUS\" > 0), LET('X', (\"X\" + \"row\".\"LASTCENSUS\")))))", code.toString()); |
188 | 188 |
} |
189 | 189 |
|
190 |
public void testSelect4() { |
|
191 |
StringBuilder source = new StringBuilder(); |
|
192 |
source.append("BEGIN "); |
|
193 |
source.append(" SET X = 0; "); |
|
194 |
source.append(" FOR row in SELECT * FROM countries "); |
|
195 |
source.append(" LOOP "); |
|
196 |
source.append(" IF row.LASTCENSUS > 0 THEN "); |
|
197 |
source.append(" SET X = X + row.LASTCENSUS "); |
|
198 |
source.append(" END IF "); |
|
199 |
source.append(" END LOOP "); |
|
200 |
source.append("END"); |
|
201 |
|
|
202 |
Compiler compiler = createCompiler(); |
|
203 |
|
|
204 |
Code code = compiler.compileExpression(source.toString()); |
|
205 |
link(code); |
|
206 |
checkEquals("testSelect4", "BLOCK(LET('X', 0), FOREACH('row', SELECT(TUPLE(), \"countries\", NULL, TUPLE(), TUPLE(), NULL), IF((\"row\".\"LASTCENSUS\" > 0), LET('X', (\"X\" + \"row\".\"LASTCENSUS\")))))", code.toString()); |
|
207 |
} |
|
208 |
|
|
190 | 209 |
public void testSelectWhere() { |
191 | 210 |
StringBuilder source = new StringBuilder(); |
192 | 211 |
source.append("SELECT * FROM countries "); |
Also available in: Unified diff