From 196db2ef0cd44c3fb542b86be7929bd01d83e138 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 12 Aug 2021 22:33:47 -0400 Subject: Put rdf:type properties first when pretty-printing This is a common convention in Turtle and TriG because the special "a" syntax for rdf type as the first property looks nice, makes things easier to read, and can be useful for streaming implementations because the type of the instance is known before reading its properties. Also significantly clean up the pretty-printing implementation in the process. --- test/test_sort.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'test/test_sort.py') diff --git a/test/test_sort.py b/test/test_sort.py index 4080b93c..04c8ba10 100755 --- a/test/test_sort.py +++ b/test/test_sort.py @@ -28,15 +28,17 @@ collations = [ ] -def check(test_dir, command_prefix, out_dir, input_path, name): +def check(test_dir, command_prefix, out_dir, input_path, name, flags=None): """Sort a single input in the named order and check the output. - The expected output is assumed to exist at test_dir/NAME.nq. + The expected output is assumed to exist at test_dir/NAME.untyped.nq. """ output_path = os.path.join(out_dir, name + ".nq") result_path = os.path.join(test_dir, name + ".nq") - options = [] if name == "pretty" else ["-c", name] + options = flags if flags is not None else [] + if name not in ["pretty", "untyped"]: + options += ["-c", name] # Randomly add irrelevant options just to cover them if random.choice([True, False]): @@ -68,10 +70,18 @@ def run_tests(test_dir, command_prefix, out_dir): input_trig = os.path.join(test_dir, "input.trig") n_failures = 0 + + # Test all the basic collations, and "pretty" with type first for name in collations: if not check(test_dir, command_prefix, out_dir, input_trig, name): n_failures += 1 + # Test "pretty" without type first + if not check( + test_dir, command_prefix, out_dir, input_trig, "untyped", ["-t"] + ): + n_failures += 1 + return n_failures -- cgit v1.2.1