aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy/servo_tidy_tests
diff options
context:
space:
mode:
authorYuki Izumi <kivikakk@github.com>2016-11-07 19:02:22 +1100
committerYuki Izumi <kivikakk@github.com>2016-11-07 19:02:22 +1100
commitd47aca18c4bb199feb1cd4674defaa27ce71ee85 (patch)
tree3c78a320e385252ad6eeef7e9c5d1cfe8b79fa32 /python/tidy/servo_tidy_tests
parentc62ce53efa75c1d817669253036c2621caac88bf (diff)
downloadservo-d47aca18c4bb199feb1cd4674defaa27ce71ee85.tar.gz
servo-d47aca18c4bb199feb1cd4674defaa27ce71ee85.zip
Check for JSON key non-duplication and order
Diffstat (limited to 'python/tidy/servo_tidy_tests')
-rw-r--r--python/tidy/servo_tidy_tests/test_tidy.py6
-rw-r--r--python/tidy/servo_tidy_tests/unordered_key.json7
2 files changed, 13 insertions, 0 deletions
diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py
index d997bb00f82..6dd97aee7e3 100644
--- a/python/tidy/servo_tidy_tests/test_tidy.py
+++ b/python/tidy/servo_tidy_tests/test_tidy.py
@@ -171,6 +171,12 @@ class CheckTidiness(unittest.TestCase):
self.assertEqual('Duplicated Key (the_duplicated_key)', errors.next()[2])
self.assertNoMoreErrors(errors)
+ def test_json_with_unordered_keys(self):
+ tidy.config["check-ordered-json-keys"].append('python/tidy/servo_tidy_tests/unordered_key.json')
+ errors = tidy.collect_errors_for_files(iterFile('unordered_key.json'), [tidy.check_json], [], print_text=False)
+ self.assertEqual('Unordered key (found b before a)', errors.next()[2])
+ self.assertNoMoreErrors(errors)
+
def test_lock(self):
errors = tidy.collect_errors_for_files(iterFile('duplicated_package.lock'), [tidy.check_lock], [], print_text=False)
msg = """duplicate versions for package "test"
diff --git a/python/tidy/servo_tidy_tests/unordered_key.json b/python/tidy/servo_tidy_tests/unordered_key.json
new file mode 100644
index 00000000000..36f0a13f9c2
--- /dev/null
+++ b/python/tidy/servo_tidy_tests/unordered_key.json
@@ -0,0 +1,7 @@
+{
+ "key": "value",
+ "other_key": {
+ "b": 1,
+ "a": 2
+ }
+}