diff --git a/src/Conjure/Language/Constant.hs b/src/Conjure/Language/Constant.hs index 5b7cecbcd..a69afbc6a 100644 --- a/src/Conjure/Language/Constant.hs +++ b/src/Conjure/Language/Constant.hs @@ -104,7 +104,11 @@ instance SimpleJSON Constant where fromSimpleJSON _ (JSON.Bool b) = return (ConstantBool b) fromSimpleJSON t@TypeInt{} x@JSON.Number{} = ConstantInt TagInt <$> fromSimpleJSON t x - fromSimpleJSON t@TypeInt{} x@JSON.String{} = ConstantInt TagInt <$> fromSimpleJSON t x + fromSimpleJSON t@(TypeInt TagInt) x@JSON.String{} = ConstantInt TagInt <$> fromSimpleJSON t x + + + -- fromSimpleJSON (TypeInt (TagEnum enum_type_name)) (JSON.String value) = + -- return (ConstantEnum (Name enum_type_name) [] (Name value)) fromSimpleJSON (TypeEnum enum_type_name) (JSON.String value) = return (ConstantEnum enum_type_name [] (Name value)) diff --git a/tests/custom/json-integration/json-enum-in/data.json b/tests/custom/json-integration/json-enum-in/data.json index 242c44587..640c601ef 100644 --- a/tests/custom/json-integration/json-enum-in/data.json +++ b/tests/custom/json-integration/json-enum-in/data.json @@ -1,8 +1,8 @@ { - "p": 3, "ghouls": [ "ghost", "dracula", "zombie" - ] + ], + "y": "zombie" } \ No newline at end of file diff --git a/tests/custom/json-integration/json-enum-in/data.param b/tests/custom/json-integration/json-enum-in/data.param new file mode 100644 index 000000000..ae66a2a4f --- /dev/null +++ b/tests/custom/json-integration/json-enum-in/data.param @@ -0,0 +1,2 @@ +letting ghouls be new type enum {ghost, dracula, zombie} +letting y be zombie diff --git a/tests/custom/json-integration/json-enum-in/m.essence b/tests/custom/json-integration/json-enum-in/m.essence index bbecba348..0aa15f067 100644 --- a/tests/custom/json-integration/json-enum-in/m.essence +++ b/tests/custom/json-integration/json-enum-in/m.essence @@ -1,4 +1,5 @@ given ghouls new type enum -given p : int find x : ghouls + +given y : ghouls such that x != y diff --git a/tests/custom/json-integration/json-enum-in/run.sh b/tests/custom/json-integration/json-enum-in/run.sh index 9b72731ec..4b38b8222 100755 --- a/tests/custom/json-integration/json-enum-in/run.sh +++ b/tests/custom/json-integration/json-enum-in/run.sh @@ -1,7 +1,11 @@ rm -rf conjure-output -conjure solve m.essence data.json --output-format=json --line-width=40 --copy-solutions=no --savilerow-options -O0 --number-of-solutions=all --output-format=json --solutions-in-one-file +conjure solve m.essence data.param --output-format=json --line-width=40 --copy-solutions=no --savilerow-options -O0 --number-of-solutions=all --output-format=json --solutions-in-one-file +cat conjure-output/*.solutions.json +rm -rf conjure-output/*.solutions.json + +conjure solve m.essence data.json --output-format=json --line-width=40 --copy-solutions=no --savilerow-options -O0 --number-of-solutions=all --output-format=json --solutions-in-one-file cat conjure-output/*.solutions.json rm -rf conjure-output