Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make NullMatcher a static field on ValueMatcher.
- Loading branch information
Showing
17 changed files
with
378 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/accept.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package cypher.feature.parser | ||
|
||
import cypher.feature.parser.matchers.ValueMatcher | ||
import org.scalatest.matchers.{MatchResult, Matcher} | ||
|
||
case class accept(value: Any) extends Matcher[ValueMatcher] { | ||
|
||
override def apply(matcher: ValueMatcher): MatchResult = { | ||
MatchResult(matches = matcher.matches(value), | ||
s"$matcher did not match $value", | ||
s"$matcher unexpectedly matched $value") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...ompatibility-suite/src/test/scala/cypher/feature/parser/matchers/BooleanMatcherTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package cypher.feature.parser.matchers | ||
|
||
import cypher.feature.parser.accept | ||
import org.scalatest.FunSuite | ||
import org.scalatest.Matchers._ | ||
|
||
class BooleanMatcherTest extends FunSuite { | ||
|
||
test("should match true") { | ||
new BooleanMatcher(true) should accept(true) | ||
} | ||
|
||
test("should match false") { | ||
new BooleanMatcher(false) should accept(false) | ||
} | ||
|
||
test("should not match other values") { | ||
new BooleanMatcher(true) shouldNot accept(false) | ||
new BooleanMatcher(true) shouldNot accept(null) | ||
new BooleanMatcher(true) shouldNot accept("") | ||
|
||
new BooleanMatcher(false) shouldNot accept(true) | ||
new BooleanMatcher(false) shouldNot accept(null) | ||
new BooleanMatcher(false) shouldNot accept("") | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
.../compatibility-suite/src/test/scala/cypher/feature/parser/matchers/FloatMatcherTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package cypher.feature.parser.matchers | ||
|
||
import cypher.feature.parser.accept | ||
import org.scalatest.FunSuite | ||
import org.scalatest.Matchers._ | ||
|
||
class FloatMatcherTest extends FunSuite { | ||
|
||
test("should match simple float") { | ||
new FloatMatcher(1.0) should accept(1.0) | ||
new FloatMatcher(.1e1) should accept(1.0) | ||
} | ||
|
||
test("should match infinities") { | ||
new FloatMatcher(Double.PositiveInfinity) should accept(Double.PositiveInfinity) | ||
new FloatMatcher(Double.NegativeInfinity) should accept(Double.NegativeInfinity) | ||
} | ||
|
||
test("should match NaN") { | ||
new FloatMatcher(Double.NaN) should accept(Double.NaN) | ||
} | ||
|
||
test("should not match integers") { | ||
new FloatMatcher(1.0) shouldNot accept(1) | ||
new FloatMatcher(0.0) shouldNot accept(0) | ||
} | ||
|
||
test("should not match strings") { | ||
new FloatMatcher(0.0) shouldNot accept("0.0") | ||
new FloatMatcher(0.0e1) shouldNot accept("0") | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...ompatibility-suite/src/test/scala/cypher/feature/parser/matchers/IntegerMatcherTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package cypher.feature.parser.matchers | ||
|
||
import cypher.feature.parser.accept | ||
import org.scalatest.FunSuite | ||
import org.scalatest.Matchers._ | ||
|
||
class IntegerMatcherTest extends FunSuite { | ||
|
||
test("should match integers") { | ||
new IntegerMatcher(0) should accept(0L) | ||
new IntegerMatcher(-1) should accept(-1L) | ||
new IntegerMatcher(2) should accept(2L) | ||
} | ||
|
||
test("should only match longs") { | ||
new IntegerMatcher(0) shouldNot accept(0) | ||
new IntegerMatcher(0) shouldNot accept(0.asInstanceOf[Short]) | ||
} | ||
|
||
test("should not accept other types") { | ||
new IntegerMatcher(0) shouldNot accept(null) | ||
new IntegerMatcher(0) shouldNot accept("0") | ||
new IntegerMatcher(0) shouldNot accept(0.0) | ||
} | ||
|
||
test("should match large ints") { | ||
new IntegerMatcher(Long.MaxValue) should accept(Long.MaxValue) | ||
} | ||
|
||
} |
Oops, something went wrong.