16
16
17
17
package de .upb .cs .swt .delphi .core
18
18
19
- import de .upb .cs .swt .delphi .core .ql .Syntax
19
+ import de .upb .cs .swt .delphi .core .ql ._
20
+ import org .parboiled2 .ParseError
20
21
import org .scalatest .{FlatSpec , Matchers }
21
22
22
23
import scala .util .{Failure , Success }
@@ -166,7 +167,7 @@ class SyntaxTest extends FlatSpec with Matchers {
166
167
167
168
" Syntax.notConditionComplex" should " be valid" in {
168
169
val parseResult = new Syntax (" !!([Filter1])&&!([Filter2]<=0||!([Filter3]&&![Filter4]%\" abc\" ))" ).QueryRule .run()
169
- parseResult shouldBe a [Success [_]]
170
+ parseResult shouldBe a[Success [_]]
170
171
parseResult match {
171
172
case Success (ast) => {
172
173
ast.toString shouldEqual " AndExpr(NotExpr(NotExpr(IsTrueExpr(FieldReference(Filter1))))," +
@@ -175,4 +176,23 @@ class SyntaxTest extends FlatSpec with Matchers {
175
176
}
176
177
}
177
178
}
179
+
180
+ " Complex query" should " be valid" in {
181
+ val parser = new Syntax (" [metrics.classversion.9] > 0 && [metrics.classversion.8] = 0 && [maven.groupId] = \" com.github.xmlet\" " )
182
+ val parseResult = parser.QueryRule .run()
183
+ parseResult match {
184
+ case Success (ast) => {
185
+ ast shouldEqual
186
+ AndExpr (
187
+ AndExpr (
188
+ GreaterThanExpr (FieldReference (" metrics.classversion.9" )," 0" ),
189
+ EqualExpr (FieldReference (" metrics.classversion.8" )," 0" )),
190
+ EqualExpr (FieldReference (" maven.groupId" )," com.github.xmlet" ))
191
+ }
192
+ case Failure (exception : ParseError ) => {
193
+ fail(parser.formatError(exception))
194
+ }
195
+ case _ => fail()
196
+ }
197
+ }
178
198
}
0 commit comments