From 70c17f904b325f0510ca315975f9b2ca6647f531 Mon Sep 17 00:00:00 2001 From: Karl Ostmo Date: Sat, 12 Nov 2022 13:11:00 -0800 Subject: [PATCH] Add tests for item possession in goal criteria --- data/scenarios/Testing/00-ORDER.txt | 1 + .../Testing/858-inventory/00-ORDER.txt | 2 ++ .../858-inventory/858-counting-objective.yaml | 36 +++++++++++++++++++ .../858-possession-objective.yaml | 33 +++++++++++++++++ test/integration/Main.hs | 7 ++++ 5 files changed, 79 insertions(+) create mode 100644 data/scenarios/Testing/858-inventory/00-ORDER.txt create mode 100644 data/scenarios/Testing/858-inventory/858-counting-objective.yaml create mode 100644 data/scenarios/Testing/858-inventory/858-possession-objective.yaml diff --git a/data/scenarios/Testing/00-ORDER.txt b/data/scenarios/Testing/00-ORDER.txt index bd40edbb4..2e6b36ad7 100644 --- a/data/scenarios/Testing/00-ORDER.txt +++ b/data/scenarios/Testing/00-ORDER.txt @@ -13,4 +13,5 @@ 378-objectives.yaml 684-swap.yaml 699-movement-fail +858-inventory 710-multi-robot.yaml diff --git a/data/scenarios/Testing/858-inventory/00-ORDER.txt b/data/scenarios/Testing/858-inventory/00-ORDER.txt new file mode 100644 index 000000000..aac4a18e8 --- /dev/null +++ b/data/scenarios/Testing/858-inventory/00-ORDER.txt @@ -0,0 +1,2 @@ +858-possession-objective.yaml +858-counting-objective.yaml diff --git a/data/scenarios/Testing/858-inventory/858-counting-objective.yaml b/data/scenarios/Testing/858-inventory/858-counting-objective.yaml new file mode 100644 index 000000000..2ff0899d1 --- /dev/null +++ b/data/scenarios/Testing/858-inventory/858-counting-objective.yaml @@ -0,0 +1,36 @@ +version: 1 +name: Evaluate count of an item +description: | + The goal criteria is exactly the same as + 858-possession-objective but evaluated + with the "count" function instead. +creative: false +objectives: + - goal: + - | + Get 1 tree. + condition: |- + as base { + itemCount <- count "tree"; + return $ itemCount > 0; + }; +robots: + - name: base + dir: [0, 1] + devices: + - treads + - scanner + - grabber +solution: | + move; + grab; +known: [tree] +world: + default: [blank] + palette: + 'B': [grass, null, base] + 'w': [grass, tree] + upperleft: [0, 0] + map: |- + w + B \ No newline at end of file diff --git a/data/scenarios/Testing/858-inventory/858-possession-objective.yaml b/data/scenarios/Testing/858-inventory/858-possession-objective.yaml new file mode 100644 index 000000000..dd2781e55 --- /dev/null +++ b/data/scenarios/Testing/858-inventory/858-possession-objective.yaml @@ -0,0 +1,33 @@ +version: 1 +name: Evaluate possession of an item +description: | + test case +creative: false +objectives: + - goal: + - | + Get 1 tree. + condition: |- + as base { + has "tree"; + }; +robots: + - name: base + dir: [0, 1] + devices: + - treads + - scanner + - grabber +solution: | + move; + grab; +known: [tree] +world: + default: [blank] + palette: + 'B': [grass, null, base] + 'w': [grass, tree] + upperleft: [0, 0] + map: |- + w + B \ No newline at end of file diff --git a/test/integration/Main.hs b/test/integration/Main.hs index c01177fb9..27f55058c 100644 --- a/test/integration/Main.hs +++ b/test/integration/Main.hs @@ -47,6 +47,7 @@ import System.Environment (getEnvironment) import System.FilePath.Posix (takeExtension, ()) import System.Timeout (timeout) import Test.Tasty (TestTree, defaultMain, testGroup) +import Test.Tasty.ExpectedFailure (expectFailBecause) import Test.Tasty.HUnit (Assertion, assertBool, assertFailure, testCase) import Witch (into) @@ -183,6 +184,12 @@ testScenarioSolution _ci _em = , testSolution Default "Testing/490-harvest" , testSolution Default "Testing/504-teleport-self" , testSolution Default "Testing/508-capability-subset" + , testGroup + "Possession criteria (#858)" + [ testSolution Default "Testing/858-inventory/858-possession-objective" + , expectFailBecause "Known bug #858" $ + testSolution Default "Testing/858-inventory/858-counting-objective" + ] , testGroup "Require (#201)" [ testSolution Default "Testing/201-require/201-require-device"