Skip to content

Commit

Permalink
Update JSON-Schema-Test-Suite
Browse files Browse the repository at this point in the history
  • Loading branch information
timjb committed Oct 10, 2012
1 parent 1c129d3 commit 4092c39
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 24 deletions.
18 changes: 1 addition & 17 deletions test/Data/Aeson/Schema/Examples.hs
Expand Up @@ -16,19 +16,7 @@ examples :: (String -> IO () -> a)
-> (Graph Schema Text -> Schema Text -> Value -> IO ()) -> (Graph Schema Text -> Schema Text -> Value -> IO ())
-> [a] -> [a]
examples testCase assertValid' assertInvalid' = examples testCase assertValid' assertInvalid' =
[ testCase "divisibleBy" $ do [ testCase "patternProperties" $ do
let by2 = [schemaQQ| { "type": "number", "divisibleBy": 2 } |]
assertValid by2 [aesonLitQQ| 2 |]
assertValid by2 [aesonLitQQ| 4 |]
assertValid by2 [aesonLitQQ| 0 |]
assertInvalid by2 [aesonLitQQ| 1 |]
assertInvalid by2 [aesonLitQQ| 3 |]
let byOneAndHalf = [schemaQQ| { "type": "number", "divisibleBy": 1.5 }]
assertValid byOneAndHalf [aesonLitQQ| 1.5 |]
assertValid byOneAndHalf [aesonLitQQ| 3 |]
assertValid byOneAndHalf [aesonLitQQ| 4.5 |]
assertInvalid byOneAndHalf [aesonLitQQ| 2.5 |]
, testCase "patternProperties" $ do
let schema = [schemaQQ| { let schema = [schemaQQ| {
"type": "object", "type": "object",
"properties": { "properties": {
Expand Down Expand Up @@ -104,10 +92,6 @@ examples testCase assertValid' assertInvalid' =
assertValid everythingExceptNumbers [aesonLitQQ| { "eins": 1, "zwei": 2 } |] assertValid everythingExceptNumbers [aesonLitQQ| { "eins": 1, "zwei": 2 } |]
assertValid everythingExceptNumbers [aesonLitQQ| ["eins", "zwei"] |] assertValid everythingExceptNumbers [aesonLitQQ| ["eins", "zwei"] |]
assertValid everythingExceptNumbers [aesonLitQQ| null |] assertValid everythingExceptNumbers [aesonLitQQ| null |]
, testCase "format: \"regex\"" $ do
let isRegex = [schemaQQ| { "type": "string", "format": "regex" } |]
assertValid isRegex "([abc])+\\s+$"
assertInvalid isRegex "^(abc]"
, testCase "type: subschema" $ do , testCase "type: subschema" $ do
let schema = [schemaQQ| { let schema = [schemaQQ| {
"type": [ "type": [
Expand Down
16 changes: 10 additions & 6 deletions test/TestSuite.hs
Expand Up @@ -8,9 +8,13 @@ import qualified Data.Aeson.Schema.Validator.Tests
import TestSuite.Types (readSchemaTests) import TestSuite.Types (readSchemaTests)


main :: IO () main :: IO ()
main = readSchemaTests "test/test-suite/tests/draft3" >>= \schemaTests -> defaultMain main = do
[ testGroup "Data.Aeson.Schema.Types" Data.Aeson.Schema.Types.Tests.tests requiredTests <- readSchemaTests "test/test-suite/tests/draft3"
, testGroup "Data.Aeson.Schema.Validator" $ Data.Aeson.Schema.Validator.Tests.tests schemaTests optionalTests <- readSchemaTests "test/test-suite/tests/draft3/optional"
, buildTest $ testGroup "Data.Aeson.Schema.CodeGen" <$> Data.Aeson.Schema.CodeGen.Tests.tests schemaTests let schemaTests = requiredTests ++ optionalTests
, testGroup "Data.Aeson.Schema.Choice" Data.Aeson.Schema.Choice.Tests.tests defaultMain
] [ testGroup "Data.Aeson.Schema.Types" Data.Aeson.Schema.Types.Tests.tests
, testGroup "Data.Aeson.Schema.Validator" $ Data.Aeson.Schema.Validator.Tests.tests schemaTests
, buildTest $ testGroup "Data.Aeson.Schema.CodeGen" <$> Data.Aeson.Schema.CodeGen.Tests.tests schemaTests
, testGroup "Data.Aeson.Schema.Choice" Data.Aeson.Schema.Choice.Tests.tests
]
2 changes: 1 addition & 1 deletion test/test-suite

0 comments on commit 4092c39

Please sign in to comment.