summaryrefslogtreecommitdiff
path: root/json
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2012-12-24 19:53:41 -0500
committerJulian Berman <Julian@GrayVines.com>2012-12-24 19:53:41 -0500
commitc41787bf3897ae903c4d1fa03d7b94f65e445552 (patch)
treedee4fbe62e1c973fd24f4933e1c1e4d51705554a /json
parent898ebd9ac665eff1d736db2c71a1e7dccf76954c (diff)
downloadjsonschema-c41787bf3897ae903c4d1fa03d7b94f65e445552.tar.gz
OK, let's see if this worked. Updated test suite.
Squashed commit of the following: commit b255d27aeca09583415fca8616e68eeaa2fd3eeb Author: Julian Berman <Julian@GrayVines.com> Date: Mon Dec 24 19:41:09 2012 -0500 Add tests for ignoring irrelevant types. commit 71a0d30e0cafce6876f23ab6cf25365d1244e0cd Merge: 2262a91 082e844 Author: Julian Berman <Julian@GrayVines.com> Date: Sun Dec 23 21:14:38 2012 -0500 Tag version 1.0.0. Closes #13 commit 082e8440ccbf29181b8ba6f440d89f4723b841df Author: Julian Berman <Julian@GrayVines.com> Date: Sun Dec 23 00:28:48 2012 -0500 Cleanup * Make errors in the tests be failures * Removed use of ErrorTree * Added another helper fn * Use fnmatch instead of glob commit e39d53703cbf4047b4fcd864dc55ad412c4c9d1d Author: Julian Berman <Julian@GrayVines.com> Date: Fri Dec 21 14:52:16 2012 -0500 Added tests differentiating between lexical and mathematical integers. Integer literals should be considered integers, while mathematical integers can be specified with divisibleBy. See: https://github.com/json-schema/json-schema/issues/27 Closes #2 commit 44540b712d330625379ab3a85fa33aca044b29cd Author: Julian Berman <Julian@GrayVines.com> Date: Fri Dec 21 14:47:26 2012 -0500 Added name to license. commit 646a9810aa69ca3a1fd14dc4282d4191cc222436 Author: Julian Berman <Julian@GrayVines.com> Date: Fri Dec 21 14:31:47 2012 -0500 Add a test for BigNum integers. Closes #12 commit d22c24ea996491f839f5f5c8447ad30f2087eebb Merge: e8bcd5a c0dbbb5 Author: Julian Berman <Julian@GrayVines.com> Date: Wed Dec 19 10:57:03 2012 -0800 Merge pull request #17 from gazpachoking/validate_suite_content Add sanity checks for actual format of test suites commit c0dbbb5320d33763b186ff40aa0292c6170588ef Author: Chase Sterling <chase.sterling@gmail.com> Date: Wed Dec 19 10:53:57 2012 -0500 Add back executable bit to suite_sanity_check commit 86f348605b35b9777691a0498f720c9dba2fb500 Author: Chase Sterling <chase.sterling@gmail.com> Date: Wed Dec 19 00:49:20 2012 -0500 Add sanity check to validate all suites against suite schema. Make sure optional test suites don't skip the sanity checks. commit e8bcd5a1f064eadd4acf4be16bf92412f9fd0e54 Author: Nick Lombard <github@jigsoft.co.za> Date: Wed Dec 19 06:38:00 2012 +0200 Update README.md Travis status for develop branch commit ca8f1071db80ce5f256927d3cad8af8404c768b9 Author: Nick Lombard <github@jigsoft.co.za> Date: Wed Dec 19 06:36:03 2012 +0200 Update README.md Added travis status image commit cf4597e140d1f713f9f7f34c2cb03da869a3224e Author: Julian Berman <Julian+git@GrayVines.com> Date: Tue Dec 18 23:27:13 2012 -0500 Minor formatting (and get travis to build) commit 5cb630c9ee5c8eecb06332d65f784538e451bc31 Author: Julian Berman <Julian+git@GrayVines.com> Date: Tue Dec 18 23:12:42 2012 -0500 Show number of tests found commit 7baea07ecbb64edf7bd4dab6f11139672298d3fd Author: Julian Berman <Julian+git@GrayVines.com> Date: Tue Dec 18 23:11:33 2012 -0500 Travis commit 2f320bb1c0e7514e7e03fe6049413c974fc844ec Author: Julian Berman <Julian+git@GrayVines.com> Date: Tue Dec 18 23:07:23 2012 -0500 Add sanity checker. commit 2262a9141c1f147c237adbeea540f66018349c5f Merge: 9cda89e a1ec588 Author: Julian Berman <Julian@GrayVines.com> Date: Tue Dec 18 13:22:23 2012 -0800 Merge pull request #15 from tdegrunt/patch-1 Update README.md commit a1ec58862c20ea4c98d5c6a26024e83145453b03 Author: Tom de Grunt <tom@degrunt.nl> Date: Tue Dec 18 22:10:48 2012 +0100 Update README.md Added node.js module jsonschema. commit 9cda89ee01a4cc9e86a215b3b9ff0468b59714a0 Author: Julian Berman <Julian@GrayVines.com> Date: Tue Dec 18 14:35:19 2012 -0500 Update README.md commit b22d795b9863d02e9fd4891ffde153ad41c4f1cb Author: Julian Berman <Julian+git@GrayVines.com> Date: Sat Nov 17 19:26:21 2012 -0500 Ignore TODO commit 330fd4864fa55b3b6bed8287cf3bdcbc2c639798 Author: Julian Berman <Julian+git@GrayVines.com> Date: Sat Nov 17 19:25:27 2012 -0500 Merge into properties tests. commit c7c2338380efebf6b89c9b81552962736fcf0b84 Author: Julian Berman <Julian+git@GrayVines.com> Date: Sat Nov 17 19:20:25 2012 -0500 Remove duplicate tests. commit 281c28be60f87fe231815b8faebc1e6169233be5 Merge: 6f55ff5 6c28d7c Author: Julian Berman <Julian+git@GrayVines.com> Date: Sat Nov 17 19:14:19 2012 -0500 Merge git://github.com/IreneKnapp/JSON-Schema-Test-Suite commit 6c28d7cb5fce73dd2cea792c151bb002501aa6ed Author: Irene Knapp <irene.knapp@icloud.com> Date: Fri Nov 16 08:33:30 2012 -0500 Fix a test that should actually be invalid. Remove some unnecessary tests. commit b7858cc3584ce8a8886a7edde3866f9776505b6f Author: Irene Knapp <irene.knapp@icloud.com> Date: Thu Nov 15 22:48:09 2012 -0500 Port over the rest of the stuff from jsonschema (the Python project). commit fa666236d2d4386ff3f17589d3f5f9416f3280df Author: Irene Knapp <irene.knapp@icloud.com> Date: Thu Nov 15 16:37:56 2012 -0500 Port roughly the first third of jsonschema (the Python project)'s tests.py. commit 6f55ff5138a561999df5b8ee27324856466eca6e Author: Julian Berman <Julian+git@GrayVines.com> Date: Thu Nov 15 14:46:48 2012 -0500 Add the haskell thing that was using us. commit 756c8257ca5a9e4de08a27f716844d24ee99432f Merge: d735a8a 459dd98 Author: Julian Berman <Julian@GrayVines.com> Date: Thu Nov 15 11:44:08 2012 -0800 Merge pull request #6 from IreneKnapp/master Add direct-schema to list of clients commit 459dd98563fbeb840ce8202a1ce72a24199a87c7 Author: Irene Knapp <irene.knapp@icloud.com> Date: Thu Nov 15 14:40:41 2012 -0500 Adding direct-schema to list of clients. commit d735a8a9de59e1ed7e0bf660b7aba0925c0f1cfa Author: Julian Berman <Julian+git@GrayVines.com> Date: Thu Nov 15 09:37:03 2012 -0500 Add call to action. commit ca78ea844e6ca0d4d43885630d122687982d4746 Author: Julian Berman <Julian+git@GrayVines.com> Date: Thu Nov 1 08:58:50 2012 -0400 Add heterogeneous types unique test. commit 4ab01de94340e6baed2344f0b949043ca35ddfaa Author: Julian Berman <Julian+git@GrayVines.com> Date: Wed Oct 31 20:12:53 2012 -0400 Add specific test for bool and int. commit 6a52026b0d5f1b687d5a995a1591b99d30240280 Author: Julian Berman <Julian+git@GrayVines.com> Date: Wed Oct 31 20:12:38 2012 -0400 Simplify test to remove also testing integers and booleans. commit 3871deac9d5cbc50635533736b68da2feaac0a1d Merge: fefa4dc 6f18358 Author: Julian Berman <Julian+git@GrayVines.com> Date: Wed Oct 10 17:39:19 2012 -0400 Merge branch 'render' commit 6f18358cc498bb0ed5dfcef08bca52408bf717e9 Author: Julian Berman <Julian+git@GrayVines.com> Date: Wed Oct 10 17:37:54 2012 -0400 Fix README example. commit fefa4dc1c72f75c605aeb8138c39468e8240e724 Merge: 189e231 295d43a Author: Julian Berman <Julian@GrayVines.com> Date: Wed Oct 10 12:47:28 2012 -0700 Merge pull request #5 from timjb/master Added tests for divisibleBy, format: "regex" commit 295d43a61daf4098864137c71b652c3d18ee33f3 Author: Tim Baumann <tim@timbaumann.info> Date: Wed Oct 10 21:27:32 2012 +0200 Move format.json to folder for optional tests commit 8f5d9e281b18296baa6440a8caa8955cf5eaec5e Author: Tim Baumann <tim@timbaumann.info> Date: Wed Oct 10 21:06:08 2012 +0200 regex validation commit f11ddc3615460fa4fc9a0e2de8efde856d138f2f Author: Tim Baumann <tim@timbaumann.info> Date: Wed Oct 10 20:59:55 2012 +0200 divisibleBy tests commit 189e231e65d2f25f722fa362cb770ef1c264f7a2 Author: Julian Berman <Julian+git@GrayVines.com> Date: Wed Oct 10 10:00:42 2012 -0400 Fix the additionalItems tests. Closes #4 commit a0a6e71207e4cf2c2821370320cc8e158cd70f4c Author: Julian Berman <Julian+git@GrayVines.com> Date: Wed Oct 10 09:54:52 2012 -0400 Fix nil. Closes #3 commit 8dbaf210b8430c8cd1058b22cc2bfc639bcbbf8b Author: Julian Berman <Julian+git@GrayVines.com> Date: Tue Oct 9 20:28:09 2012 -0400 Fix line endings and add invalid test case. commit 7829853a2fffa508557c1e21613709417e603f09 Author: Julian Berman <Julian+git@GrayVines.com> Date: Sun Oct 7 10:33:14 2012 -0400 required commit 91e57ae1dc09d75c3885bb8124213f5e67bf2275 Author: Julian Berman <Julian+git@GrayVines.com> Date: Sun Oct 7 10:24:35 2012 -0400 Pattern commit 49af2ebc9a02584fe84ee8b414930b70af24637e Author: Julian Berman <Julian+git@GrayVines.com> Date: Sat Oct 6 20:50:59 2012 -0400 uniqueItems commit 089ed8e819d598125bbac985aa292f78be1e1547 Author: Julian Berman <Julian+git@GrayVines.com> Date: Sat Oct 6 20:50:23 2012 -0400 Enum commit 7e4b937146d92a8612e9b95074daf7582f6ace65 Author: Julian Berman <Julian+git@GrayVines.com> Date: Sat Oct 6 20:40:53 2012 -0400 max/min Items/Length commit 5c27f85a33bc75a8cfddf3b66d2bae91eac9b21e Author: Julian Berman <Julian+git@GrayVines.com> Date: Sat Oct 6 20:34:21 2012 -0400 Minimum and maximum commit 9e24adbd197dddd31d74743bbc203534eda07e9e Merge: 3649b58 3498f34 Author: Julian Berman <Julian@GrayVines.com> Date: Wed Sep 26 17:16:27 2012 -0700 Merge pull request #1 from gazpachoking/clean Add some more tests commit 3498f34e94db6e20f8202c0638005d2f62931ab7 Author: Chase Sterling <chase.sterling@gmail.com> Date: Wed Sep 26 20:02:58 2012 -0400 Fix an improper additionalItems test. commit 26a3873400e6c644cbe22842565624b40c410f1e Merge: baf0502 3649b58 Author: Chase Sterling <chase.sterling@gmail.com> Date: Tue Sep 25 16:48:39 2012 -0400 Merge branch 'master' into clean commit baf050206e12334dfe158390a9d8f8d5525b3d6d Author: Chase Sterling <chase.sterling@gmail.com> Date: Tue Sep 25 16:48:30 2012 -0400 Added items tests. commit cb6dfb2f040c1cc581128a0fbd2a40cfa44fb994 Author: Chase Sterling <chase.sterling@gmail.com> Date: Tue Sep 25 16:11:21 2012 -0400 Add cleaned up additionalItems commit 3649b58a5ce8fefc77ee1cfaaaeaf68df278ebd6 Author: Julian Berman <Julian+git@GrayVines.com> Date: Tue Sep 25 15:28:13 2012 -0400 Would be nice if I'd have properly run lint. commit e6a270f18c77a1218abc3a7137a093a757b071db Author: Julian Berman <Julian+git@GrayVines.com> Date: Tue Sep 25 15:00:57 2012 -0400 Properties. commit 2192a637eff388a4ee666b07635922281e78539f Author: Julian Berman <Julian+git@GrayVines.com> Date: Tue Sep 25 12:40:31 2012 -0400 Clarify test reqs. commit ff746d00529dd7df0e56329223a8f16933aff9d1 Author: Julian Berman <Julian+git@GrayVines.com> Date: Tue Sep 25 12:34:22 2012 -0400 Add MIT License. commit 9271ce51a4e053fe40985b17c1f88715bd859eb6 Author: Julian Berman <Julian+git@GrayVines.com> Date: Tue Sep 25 12:29:00 2012 -0400 A basic readme. commit 530a0f33201ce4d718d5859f4856a65bbbcdcc73 Author: Julian Berman <Julian+git@GrayVines.com> Date: Tue Sep 25 12:12:43 2012 -0400 Finish type tests. commit 4f9cd46dd9f73a1903452b1a9f4ea99c1938fb50 Author: Julian Berman <Julian+git@GrayVines.com> Date: Tue Sep 25 11:49:34 2012 -0400 Initial commit. Basic type tests.
Diffstat (limited to 'json')
-rw-r--r--json/.travis.yml4
-rw-r--r--json/LICENSE2
-rw-r--r--json/README.md35
-rwxr-xr-xjson/bin/suite_sanity_check116
-rw-r--r--json/tests/draft3/additionalItems.json5
-rw-r--r--json/tests/draft3/additionalProperties.json5
-rw-r--r--json/tests/draft3/dependencies.json5
-rw-r--r--json/tests/draft3/divisibleBy.json37
-rw-r--r--json/tests/draft3/items.json87
-rw-r--r--json/tests/draft3/maxItems.json5
-rw-r--r--json/tests/draft3/maxLength.json5
-rw-r--r--json/tests/draft3/maximum.json5
-rw-r--r--json/tests/draft3/minItems.json5
-rw-r--r--json/tests/draft3/minLength.json5
-rw-r--r--json/tests/draft3/minimum.json5
-rw-r--r--json/tests/draft3/optional/bignum.json13
-rw-r--r--json/tests/draft3/pattern.json5
-rw-r--r--json/tests/draft3/properties.json5
-rw-r--r--json/tests/draft3/type.json5
-rw-r--r--json/tests/draft3/uniqueItems.json5
20 files changed, 277 insertions, 82 deletions
diff --git a/json/.travis.yml b/json/.travis.yml
new file mode 100644
index 0000000..186bd12
--- /dev/null
+++ b/json/.travis.yml
@@ -0,0 +1,4 @@
+language: python
+python: "2.7"
+install: pip install jsonschema
+script: bin/suite_sanity_check -v
diff --git a/json/LICENSE b/json/LICENSE
index 3dca8a2..c28adba 100644
--- a/json/LICENSE
+++ b/json/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2012
+Copyright (c) 2012 Julian Berman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/json/README.md b/json/README.md
index 4f8549b..b0c2a3d 100644
--- a/json/README.md
+++ b/json/README.md
@@ -1,4 +1,4 @@
-JSON Schema Test Suite
+JSON Schema Test Suite [![Build Status](https://travis-ci.org/json-schema/JSON-Schema-Test-Suite.png?branch=develop)](https://travis-ci.org/json-schema/JSON-Schema-Test-Suite)
======================
This repository contains a set of JSON objects that implementors of JSON Schema
@@ -6,8 +6,8 @@ validation libraries can use to test their validators.
It is meant to be language agnostic and should require only a JSON parser.
-The conversion of the JSON objects into your test framework of choice (say,
-an `xUnit`) is still the job of the validator implementor.
+The conversion of the JSON objects into tests within your test framework of
+choice is still the job of the validator implementor.
Structure of a Test
-------------------
@@ -19,7 +19,9 @@ Inside that directory is a subdirectory for each draft or version of the
schema. We'll use `draft3` as an example.
If you look inside the draft directory, there are a number of `.json` files,
-which logically group a set of test cases together.
+which logically group a set of test cases together. Often the grouping is by
+property under test, but not always, especially within optional test files
+(discussed below).
Inside each `.json` file is a single array containing objects. It's easiest to
illustrate the structure of these with an example:
@@ -27,7 +29,7 @@ illustrate the structure of these with an example:
```json
{
"description": "the description of the test case",
- "schema": "the schema that should be validated against",
+ "schema": {"the schema that should" : "be validated against"},
"tests": [
{
"description": "a specific test of a valid instance",
@@ -50,11 +52,9 @@ they should be valid or invalid.
Coverage
--------
-The coverage of this suite is actively growing. The first order of business is
-to have a full-coverage draft 3 test suite.
+Currently, draft 3 should have essentially full coverage for the core schema.
-Ultimately, when it's done, the idea is to attempt to have it included on [the
-JSON Schema website](http://www.json-schema.org).
+The beginnings of draft 4 are underway.
Who Uses the Test Suite
-----------------------
@@ -64,6 +64,7 @@ This suite is being used by:
* [jsonschema (python)](https://github.com/Julian/jsonschema)
* [aeson-schema (haskell)](https://github.com/timjb/aeson-schema)
* [direct-schema (javascript)](https://github.com/IreneKnapp/direct-schema)
+ * [jsonschema (javascript)](https://github.com/tdegrunt/jsonschema)
If you use it as well, please fork and send a pull request adding yourself to
the list :).
@@ -71,18 +72,4 @@ the list :).
Contributing
------------
-I need help! If you'd like to contribute, please fork this repository. I'd love
-to have your pull requests sent over.
-
-Right now, the way I'm compiling the tests is by porting over a test suite
-that I'd written for a Python validator. The tests (in a messy format) can be
-found [here](https://github.com/Julian/jsonschema/blob/master/tests.py#L100).
-
-There are also other JSON Schema test suites for various other validators, and
-it would certainly be nice to merge all of them as well. In particular, [this
-validator](https://github.com/fge/json-schema-validator/tree/master/src/test/resources/keyword)
-contains a set of tests already written in JSON which will be useful.
-
-I'm perfectly fine with contributions either porting from one of those, or
-being written from scratch, so feel free to do what you're comfortable with as
-long as the tests are easy to understand and correct :).
+If you see something missing or incorrect, a pull request is most welcome!
diff --git a/json/bin/suite_sanity_check b/json/bin/suite_sanity_check
new file mode 100755
index 0000000..bc42d39
--- /dev/null
+++ b/json/bin/suite_sanity_check
@@ -0,0 +1,116 @@
+#! /usr/bin/env python
+from unittest import TestCase, skipIf
+import fnmatch
+import json
+import logging
+import os
+
+try:
+ import jsonschema
+except ImportError:
+ jsonschema = None
+
+
+logging.basicConfig(level=logging.INFO)
+
+SUITE_ROOT_DIR = os.path.join(os.path.dirname(__file__), os.pardir, "tests")
+TESTSUITE_SCHEMA = {
+ "$schema": "http://json-schema.org/draft-03/schema#",
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "description": {"type": "string", "required": True},
+ "schema": {"required": True},
+ "tests": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "description": {"type": "string", "required": True},
+ "data": {"required": True},
+ "valid": {"type": "boolean", "required": True}
+ },
+ "additionalProperties": False
+ },
+ "minItems": 1
+ }
+ },
+ "additionalProperties": False,
+ "minItems": 1
+ }
+}
+
+
+def files(paths):
+ for path in paths:
+ with open(path) as test_file:
+ yield json.load(test_file)
+
+
+def groups(paths):
+ for test_file in files(paths):
+ for group in test_file:
+ yield group
+
+
+def cases(paths):
+ for test_group in groups(paths):
+ for test in test_group["tests"]:
+ test["schema"] = test_group["schema"]
+ yield test
+
+
+def collect(root_dir):
+ for root, dirs, files in os.walk(root_dir):
+ for filename in fnmatch.filter(files, "*.json"):
+ yield os.path.join(root, filename)
+
+
+class SanityTests(TestCase):
+ @classmethod
+ def setUpClass(cls):
+ logging.info("Looking for tests in %s", SUITE_ROOT_DIR)
+ cls.test_files = list(collect(SUITE_ROOT_DIR))
+ logging.info("Found %s test files", len(cls.test_files))
+ assert cls.test_files, "Didn't find the test files!"
+
+ def test_all_files_are_valid_json(self):
+ for path in self.test_files:
+ with open(path) as test_file:
+ try:
+ json.load(test_file)
+ except ValueError as error:
+ self.fail("%s contains invalid JSON (%s)" % (path, error))
+
+ def test_all_descriptions_are_unique(self):
+ for group in groups(self.test_files):
+ descriptions = {test["description"] for test in group["tests"]}
+ self.assertEqual(
+ len(descriptions),
+ len(group["tests"]),
+ "%r contains a duplicate description" % (group,)
+ )
+
+ @skipIf(jsonschema is None, "Validation library not present! Skipping.")
+ def test_all_schemas_are_valid(self):
+ for case in cases(self.test_files):
+ # XXX: Add the other versions for the other drafts
+ try:
+ jsonschema.Draft3Validator.check_schema(case["schema"])
+ except jsonschema.SchemaError as error:
+ self.fail("%s contains an invalid schema (%s)" % (case, error))
+
+ @skipIf(jsonschema is None, "Validation library not present! Skipping.")
+ def test_suites_are_valid(self):
+ validator = jsonschema.Draft3Validator(TESTSUITE_SCHEMA)
+ for tests in files(self.test_files):
+ try:
+ validator.validate(tests)
+ except jsonschema.ValidationError as error:
+ self.fail(str(error))
+
+
+if __name__ == "__main__":
+ from unittest import main
+ main()
diff --git a/json/tests/draft3/additionalItems.json b/json/tests/draft3/additionalItems.json
index fd40de7..6d4bff5 100644
--- a/json/tests/draft3/additionalItems.json
+++ b/json/tests/draft3/additionalItems.json
@@ -60,6 +60,11 @@
"items defaults to empty schema so everything is valid",
"data": [ 1, 2, 3, 4, 5 ],
"valid": true
+ },
+ {
+ "description": "ignores non-arrays",
+ "data": {"foo" : "bar"},
+ "valid": true
}
]
},
diff --git a/json/tests/draft3/additionalProperties.json b/json/tests/draft3/additionalProperties.json
index 24bf5c0..c997f75 100644
--- a/json/tests/draft3/additionalProperties.json
+++ b/json/tests/draft3/additionalProperties.json
@@ -16,6 +16,11 @@
"description": "an additional property is invalid",
"data": {"foo" : 1, "bar" : 2, "quux" : "boom"},
"valid": false
+ },
+ {
+ "description": "ignores non-objects",
+ "data": [1, 2, 3],
+ "valid": true
}
]
},
diff --git a/json/tests/draft3/dependencies.json b/json/tests/draft3/dependencies.json
index 4608402..2f6ae48 100644
--- a/json/tests/draft3/dependencies.json
+++ b/json/tests/draft3/dependencies.json
@@ -24,6 +24,11 @@
"description": "missing dependency",
"data": {"bar": 2},
"valid": false
+ },
+ {
+ "description": "ignores non-objects",
+ "data": "foo",
+ "valid": true
}
]
},
diff --git a/json/tests/draft3/divisibleBy.json b/json/tests/draft3/divisibleBy.json
index f4a7feb..ef7cc14 100644
--- a/json/tests/draft3/divisibleBy.json
+++ b/json/tests/draft3/divisibleBy.json
@@ -1,37 +1,42 @@
[
{
- "description": "by number",
- "schema": {"divisibleBy": 1.5},
+ "description": "by int",
+ "schema": {"divisibleBy": 2},
"tests": [
{
- "description": "zero is divisible by anything (except 0)",
- "data": 0,
+ "description": "int by int",
+ "data": 10,
"valid": true
},
{
- "description": "4.5 is divisible by 1.5",
- "data": 4.5,
- "valid": true
+ "description": "int by int fail",
+ "data": 7,
+ "valid": false
},
{
- "description": "35 is not divisible by 1.5",
- "data": 35,
- "valid": false
+ "description": "ignores non-numbers",
+ "data": "foo",
+ "valid": true
}
]
},
{
- "description": "by int",
- "schema": {"divisibleBy": 2},
+ "description": "by number",
+ "schema": {"divisibleBy": 1.5},
"tests": [
{
- "description": "int by int",
- "data": 10,
+ "description": "zero is divisible by anything (except 0)",
+ "data": 0,
"valid": true
},
{
- "description": "int by int fail",
- "data": 7,
+ "description": "4.5 is divisible by 1.5",
+ "data": 4.5,
+ "valid": true
+ },
+ {
+ "description": "35 is not divisible by 1.5",
+ "data": 35,
"valid": false
}
]
diff --git a/json/tests/draft3/items.json b/json/tests/draft3/items.json
index 9e16263..f5e18a1 100644
--- a/json/tests/draft3/items.json
+++ b/json/tests/draft3/items.json
@@ -1,41 +1,46 @@
-[
- {
- "description": "a schema given for items",
- "schema": {
- "items": {"type": "integer"}
- },
- "tests": [
- {
- "description": "valid items",
- "data": [ 1, 2, 3 ],
- "valid": true
- },
- {
- "description": "wrong type of items",
- "data": [1, "x"],
- "valid": false
- }
- ]
- },
- {
- "description": "an array of schemas for items",
- "schema": {
- "items": [
- {"type": "integer"},
- {"type": "string"}
- ]
- },
- "tests": [
- {
- "description": "correct types",
- "data": [ 1, "foo" ],
- "valid": true
- },
- {
- "description": "wrong types",
- "data": [ "foo", 1 ],
- "valid": false
- }
- ]
- }
-] \ No newline at end of file
+[
+ {
+ "description": "a schema given for items",
+ "schema": {
+ "items": {"type": "integer"}
+ },
+ "tests": [
+ {
+ "description": "valid items",
+ "data": [ 1, 2, 3 ],
+ "valid": true
+ },
+ {
+ "description": "wrong type of items",
+ "data": [1, "x"],
+ "valid": false
+ },
+ {
+ "description": "ignores non-arrays",
+ "data": {"foo" : "bar"},
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "an array of schemas for items",
+ "schema": {
+ "items": [
+ {"type": "integer"},
+ {"type": "string"}
+ ]
+ },
+ "tests": [
+ {
+ "description": "correct types",
+ "data": [ 1, "foo" ],
+ "valid": true
+ },
+ {
+ "description": "wrong types",
+ "data": [ "foo", 1 ],
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/maxItems.json b/json/tests/draft3/maxItems.json
index da13fc2..3b53a6b 100644
--- a/json/tests/draft3/maxItems.json
+++ b/json/tests/draft3/maxItems.json
@@ -17,6 +17,11 @@
"description": "too long is invalid",
"data": [1, 2, 3],
"valid": false
+ },
+ {
+ "description": "ignores non-arrays",
+ "data": "foobar",
+ "valid": true
}
]
}
diff --git a/json/tests/draft3/maxLength.json b/json/tests/draft3/maxLength.json
index 36cba1d..561767b 100644
--- a/json/tests/draft3/maxLength.json
+++ b/json/tests/draft3/maxLength.json
@@ -17,6 +17,11 @@
"description": "too long is invalid",
"data": "foo",
"valid": false
+ },
+ {
+ "description": "ignores non-strings",
+ "data": 10,
+ "valid": true
}
]
}
diff --git a/json/tests/draft3/maximum.json b/json/tests/draft3/maximum.json
index 3c8cd86..86c7b89 100644
--- a/json/tests/draft3/maximum.json
+++ b/json/tests/draft3/maximum.json
@@ -12,6 +12,11 @@
"description": "above the maximum is invalid",
"data": 3.5,
"valid": false
+ },
+ {
+ "description": "ignores non-numbers",
+ "data": "x",
+ "valid": true
}
]
},
diff --git a/json/tests/draft3/minItems.json b/json/tests/draft3/minItems.json
index 351fa50..ed51188 100644
--- a/json/tests/draft3/minItems.json
+++ b/json/tests/draft3/minItems.json
@@ -17,6 +17,11 @@
"description": "too short is invalid",
"data": [],
"valid": false
+ },
+ {
+ "description": "ignores non-arrays",
+ "data": "",
+ "valid": true
}
]
}
diff --git a/json/tests/draft3/minLength.json b/json/tests/draft3/minLength.json
index 795fb08..e9c14b1 100644
--- a/json/tests/draft3/minLength.json
+++ b/json/tests/draft3/minLength.json
@@ -17,6 +17,11 @@
"description": "too short is invalid",
"data": "f",
"valid": false
+ },
+ {
+ "description": "ignores non-strings",
+ "data": 1,
+ "valid": true
}
]
}
diff --git a/json/tests/draft3/minimum.json b/json/tests/draft3/minimum.json
index d99a899..d5bf000 100644
--- a/json/tests/draft3/minimum.json
+++ b/json/tests/draft3/minimum.json
@@ -12,6 +12,11 @@
"description": "below the minimum is invalid",
"data": 0.6,
"valid": false
+ },
+ {
+ "description": "ignores non-numbers",
+ "data": "x",
+ "valid": true
}
]
},
diff --git a/json/tests/draft3/optional/bignum.json b/json/tests/draft3/optional/bignum.json
new file mode 100644
index 0000000..47a87d9
--- /dev/null
+++ b/json/tests/draft3/optional/bignum.json
@@ -0,0 +1,13 @@
+[
+ {
+ "description": "support for bignums",
+ "schema": {"type": "integer"},
+ "tests": [
+ {
+ "description": "a bignum is an integer",
+ "data": 12345678910111213141516171819202122232425262728293031,
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/pattern.json b/json/tests/draft3/pattern.json
index 905930e..befc4b5 100644
--- a/json/tests/draft3/pattern.json
+++ b/json/tests/draft3/pattern.json
@@ -12,6 +12,11 @@
"description": "a non-matching pattern is invalid",
"data": "abc",
"valid": false
+ },
+ {
+ "description": "ignores non-strings",
+ "data": true,
+ "valid": true
}
]
}
diff --git a/json/tests/draft3/properties.json b/json/tests/draft3/properties.json
index ae9a14c..cd1644d 100644
--- a/json/tests/draft3/properties.json
+++ b/json/tests/draft3/properties.json
@@ -27,6 +27,11 @@
"description": "doesn't invalidate other properties",
"data": {"quux": []},
"valid": true
+ },
+ {
+ "description": "ignores non-objects",
+ "data": [],
+ "valid": true
}
]
},
diff --git a/json/tests/draft3/type.json b/json/tests/draft3/type.json
index 8f10889..2679ce3 100644
--- a/json/tests/draft3/type.json
+++ b/json/tests/draft3/type.json
@@ -14,6 +14,11 @@
"valid": false
},
{
+ "description": "a float is not an integer even without fractional part",
+ "data": 1.0,
+ "valid": false
+ },
+ {
"description": "a string is not an integer",
"data": "foo",
"valid": false
diff --git a/json/tests/draft3/uniqueItems.json b/json/tests/draft3/uniqueItems.json
index ee1264e..c1f4ab9 100644
--- a/json/tests/draft3/uniqueItems.json
+++ b/json/tests/draft3/uniqueItems.json
@@ -14,6 +14,11 @@
"valid": false
},
{
+ "description": "numbers are unique if mathematically unequal",
+ "data": [1.0, 1.00, 1],
+ "valid": false
+ },
+ {
"description": "unique array of objects is valid",
"data": [{"foo": "bar"}, {"foo": "baz"}],
"valid": true