From 53dbca1f3de8183eefdb0c6b2d0e384f1371e52e Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Mon, 7 Dec 2020 16:30:26 +0000 Subject: Change ConjunctiveQuery constructors interface One of the object constructor was returning an Option. It was weird to have a constructor that would not always return an object. --- .../ac/ox/cs/rsacomb/FilteringProgramSpecs.scala | 8 +++---- .../cs/rsacomb/sparql/ConjunctiveQuerySpec.scala | 28 +++++++++++----------- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/test/scala/uk') diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/FilteringProgramSpecs.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/FilteringProgramSpecs.scala index 86e0253..93e312c 100644 --- a/src/test/scala/uk/ac/ox/cs/rsacomb/FilteringProgramSpecs.scala +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/FilteringProgramSpecs.scala @@ -66,28 +66,28 @@ class FilteringProgramSpec extends AnyFlatSpec with Matchers { import FilteringProgramSpec._ "CQ 0" should "generate 27 rules and 3 facts" in { - val cq = ConjunctiveQuery(cq0).get + val cq = ConjunctiveQuery.parse(cq0).get val filter = FilteringProgram(cq, constants) filter.facts should have length 3 filter.rules should have length 27 } "CQ 1" should "generate 15 rules" in { - val cq = ConjunctiveQuery(cq1).get + val cq = ConjunctiveQuery.parse(cq1).get val filter = FilteringProgram(cq, List()) filter.facts shouldBe empty filter.rules should have length 15 } "CQ 2" should "generate 51 rules" in { - val cq = ConjunctiveQuery(cq2).get + val cq = ConjunctiveQuery.parse(cq2).get val filter = FilteringProgram(cq, List()) filter.facts shouldBe empty filter.rules should have length 51 } "BCQ 0" should "generate 46 rules" in { - val cq = ConjunctiveQuery(bcq0).get + val cq = ConjunctiveQuery.parse(bcq0).get val filter = FilteringProgram(cq, constants) filter.facts should have length 3 filter.rules should have length 43 diff --git a/src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQuerySpec.scala b/src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQuerySpec.scala index 07e7bfb..7938174 100644 --- a/src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQuerySpec.scala +++ b/src/test/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQuerySpec.scala @@ -142,35 +142,35 @@ class ConjunctiveQuerySpec import ConjunctiveQuerySpec._ "A conjunctive query" should "result in a `ConjunctiveQuery` instance" in { - ConjunctiveQuery(cq0) shouldBe defined + ConjunctiveQuery.parse(cq0) shouldBe defined } "A boolean conjunctive query" should "result in a `ConjunctiveQuery` instance" in { - ConjunctiveQuery(bcq0) shouldBe defined + ConjunctiveQuery.parse(bcq0) shouldBe defined } "A query with proper SELECT defined" should "not be a BCQ" in { - ConjunctiveQuery(cq0).value should not be 'bcq + ConjunctiveQuery.parse(cq0).value should not be 'bcq } "A query with a \"*\" SELECT" should "not be a BCQ" in { - ConjunctiveQuery(cq1).value should not be 'bcq + ConjunctiveQuery.parse(cq1).value should not be 'bcq } "An ASK query" should "not be a BCQ" in { - ConjunctiveQuery(bcq0).value shouldBe 'bcq + ConjunctiveQuery.parse(bcq0).value shouldBe 'bcq } "Queries" should "have distinct answer and bounded variables" in { for (q <- queries) { - val cq = ConjunctiveQuery(q) + val cq = ConjunctiveQuery.parse(q) forAll(cq.value.answer) { v => cq.value.bounded should not contain v } forAll(cq.value.bounded) { v => cq.value.answer should not contain v } } } "CQ0" should "have {?obj, ?pred} as bounded variables" in { - ConjunctiveQuery(cq0).value.bounded should contain theSameElementsAs + ConjunctiveQuery.parse(cq0).value.bounded should contain theSameElementsAs List( Variable.create("Y"), Variable.create("Z") @@ -178,15 +178,15 @@ class ConjunctiveQuerySpec } "CQ1" should "have no bounded variable" in { - ConjunctiveQuery(cq1).value.bounded shouldBe empty + ConjunctiveQuery.parse(cq1).value.bounded shouldBe empty } "CQ2" should "have no bounded variable" in { - ConjunctiveQuery(cq2).value.bounded shouldBe empty + ConjunctiveQuery.parse(cq2).value.bounded shouldBe empty } "CQ3" should "have {?w, ?fp} as bounded variables" in { - ConjunctiveQuery(cq3).value.bounded should contain theSameElementsAs + ConjunctiveQuery.parse(cq3).value.bounded should contain theSameElementsAs List( Variable.create("w"), Variable.create("fp") @@ -194,11 +194,11 @@ class ConjunctiveQuerySpec } "CQ4" should "have no bounded variable" in { - ConjunctiveQuery(cq4).value.bounded shouldBe empty + ConjunctiveQuery.parse(cq4).value.bounded shouldBe empty } "CQ5" should "have a non-empty bounded set" in { - ConjunctiveQuery(cq5).value.bounded should contain theSameElementsAs + ConjunctiveQuery.parse(cq5).value.bounded should contain theSameElementsAs List( Variable.create("w"), Variable.create("c_int"), @@ -208,7 +208,7 @@ class ConjunctiveQuerySpec } "CQ6" should "have a non-empty bounded set" in { - ConjunctiveQuery(cq6).value.bounded should contain theSameElementsAs + ConjunctiveQuery.parse(cq6).value.bounded should contain theSameElementsAs List( Variable.create("w"), Variable.create("int") @@ -216,7 +216,7 @@ class ConjunctiveQuerySpec } "CQ7" should "have a non-empty bounded set" in { - ConjunctiveQuery(cq7).value.bounded should contain theSameElementsAs + ConjunctiveQuery.parse(cq7).value.bounded should contain theSameElementsAs List( Variable.create("w"), Variable.create("z"), -- cgit v1.2.3