From 1409f161793a289819df1f31eccb579b71f45475 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 12 Aug 2021 22:28:59 -0400 Subject: Fix pretty-printing nested empty lists and add test suite The earlier "test" was just hitting the code without actually checking the output. This new suite is a set of pretty-printed documents which serd must reproduce from a model exactly to pass. This should make it easy to add cases in the future, since each case is just a document, as it should look. --- test/pretty/anonymous-in-list-object.ttl | 11 ++ test/pretty/anonymous-object.ttl | 10 ++ test/pretty/anonymous-subject-and-object.ttl | 4 + test/pretty/anonymous-subject.ttl | 4 + test/pretty/empty-anonymous-object.ttl | 4 + test/pretty/empty-list-object.ttl | 4 + test/pretty/empty-list-subject-and-object.ttl | 4 + test/pretty/empty-list-subject.ttl | 4 + test/pretty/list-in-object.ttl | 10 ++ test/pretty/list-object.ttl | 8 ++ test/pretty/list-subject-with-extras.ttl | 9 ++ test/pretty/list-subject-with-list-extras.ttl | 12 ++ test/pretty/list-subject.ttl | 8 ++ test/pretty/manifest.ttl | 121 +++++++++++++++++++++ test/pretty/many-objects.ttl | 9 ++ test/pretty/meson.build | 17 +++ .../pretty/nested-list-object-with-empty-lists.ttl | 11 ++ test/pretty/nested-list-object.ttl | 13 +++ test/pretty/nested-list-subject.ttl | 13 +++ 19 files changed, 276 insertions(+) create mode 100644 test/pretty/anonymous-in-list-object.ttl create mode 100644 test/pretty/anonymous-object.ttl create mode 100644 test/pretty/anonymous-subject-and-object.ttl create mode 100644 test/pretty/anonymous-subject.ttl create mode 100644 test/pretty/empty-anonymous-object.ttl create mode 100644 test/pretty/empty-list-object.ttl create mode 100644 test/pretty/empty-list-subject-and-object.ttl create mode 100644 test/pretty/empty-list-subject.ttl create mode 100644 test/pretty/list-in-object.ttl create mode 100644 test/pretty/list-object.ttl create mode 100644 test/pretty/list-subject-with-extras.ttl create mode 100644 test/pretty/list-subject-with-list-extras.ttl create mode 100644 test/pretty/list-subject.ttl create mode 100644 test/pretty/manifest.ttl create mode 100644 test/pretty/many-objects.ttl create mode 100644 test/pretty/meson.build create mode 100644 test/pretty/nested-list-object-with-empty-lists.ttl create mode 100644 test/pretty/nested-list-object.ttl create mode 100644 test/pretty/nested-list-subject.ttl (limited to 'test/pretty') diff --git a/test/pretty/anonymous-in-list-object.ttl b/test/pretty/anonymous-in-list-object.ttl new file mode 100644 index 00000000..a6b202f4 --- /dev/null +++ b/test/pretty/anonymous-in-list-object.ttl @@ -0,0 +1,11 @@ +@prefix eg: . + +eg:s + eg:p ( + [ + a eg:Spy + ] + [ + a eg:Ninja + ] + ) . diff --git a/test/pretty/anonymous-object.ttl b/test/pretty/anonymous-object.ttl new file mode 100644 index 00000000..f592fed1 --- /dev/null +++ b/test/pretty/anonymous-object.ttl @@ -0,0 +1,10 @@ +@prefix eg: . + +eg:s + eg:p1 [ + eg:p2 eg:o2 ; + eg:p3 eg:o3 + ] , [ + eg:p4 eg:o4 ; + eg:p5 eg:o5 + ] . diff --git a/test/pretty/anonymous-subject-and-object.ttl b/test/pretty/anonymous-subject-and-object.ttl new file mode 100644 index 00000000..8904cca6 --- /dev/null +++ b/test/pretty/anonymous-subject-and-object.ttl @@ -0,0 +1,4 @@ +@prefix eg: . + +[] + eg:p [] . diff --git a/test/pretty/anonymous-subject.ttl b/test/pretty/anonymous-subject.ttl new file mode 100644 index 00000000..e0e467e2 --- /dev/null +++ b/test/pretty/anonymous-subject.ttl @@ -0,0 +1,4 @@ +@prefix eg: . + +[] + eg:p eg:o . diff --git a/test/pretty/empty-anonymous-object.ttl b/test/pretty/empty-anonymous-object.ttl new file mode 100644 index 00000000..f3b8d7f7 --- /dev/null +++ b/test/pretty/empty-anonymous-object.ttl @@ -0,0 +1,4 @@ +@prefix eg: . + +eg:s + eg:p [] . diff --git a/test/pretty/empty-list-object.ttl b/test/pretty/empty-list-object.ttl new file mode 100644 index 00000000..b4045ec0 --- /dev/null +++ b/test/pretty/empty-list-object.ttl @@ -0,0 +1,4 @@ +@prefix eg: . + +eg:s + eg:list () . diff --git a/test/pretty/empty-list-subject-and-object.ttl b/test/pretty/empty-list-subject-and-object.ttl new file mode 100644 index 00000000..3b84980e --- /dev/null +++ b/test/pretty/empty-list-subject-and-object.ttl @@ -0,0 +1,4 @@ +@prefix eg: . + +() + eg:list () . diff --git a/test/pretty/empty-list-subject.ttl b/test/pretty/empty-list-subject.ttl new file mode 100644 index 00000000..0610eb07 --- /dev/null +++ b/test/pretty/empty-list-subject.ttl @@ -0,0 +1,4 @@ +@prefix eg: . + +() + a eg:ExampleList . diff --git a/test/pretty/list-in-object.ttl b/test/pretty/list-in-object.ttl new file mode 100644 index 00000000..ce887157 --- /dev/null +++ b/test/pretty/list-in-object.ttl @@ -0,0 +1,10 @@ +@prefix eg: . + +eg:s + eg:p [ + eg:list ( + "apple" + "banana" + "cherry" + ) + ] . diff --git a/test/pretty/list-object.ttl b/test/pretty/list-object.ttl new file mode 100644 index 00000000..735d9df6 --- /dev/null +++ b/test/pretty/list-object.ttl @@ -0,0 +1,8 @@ +@prefix eg: . + +eg:s + eg:list ( + "apple" + "banana" + "cherry" + ) . diff --git a/test/pretty/list-subject-with-extras.ttl b/test/pretty/list-subject-with-extras.ttl new file mode 100644 index 00000000..dcfb8753 --- /dev/null +++ b/test/pretty/list-subject-with-extras.ttl @@ -0,0 +1,9 @@ +@prefix eg: . + +( + "apple" + "banana" + "cherry" +) + eg:with eg:someProperties ; + a eg:ExampleList . diff --git a/test/pretty/list-subject-with-list-extras.ttl b/test/pretty/list-subject-with-list-extras.ttl new file mode 100644 index 00000000..0a0cd0e0 --- /dev/null +++ b/test/pretty/list-subject-with-list-extras.ttl @@ -0,0 +1,12 @@ +@prefix eg: . + +( + "apple" + "banana" + "cherry" +) + eg:list ( + "asparagus" + "beet" + "carrot" + ) . diff --git a/test/pretty/list-subject.ttl b/test/pretty/list-subject.ttl new file mode 100644 index 00000000..eb1c7a2e --- /dev/null +++ b/test/pretty/list-subject.ttl @@ -0,0 +1,8 @@ +@prefix eg: . + +( + "apple" + "banana" + "cherry" +) + a eg:ExampleList . diff --git a/test/pretty/manifest.ttl b/test/pretty/manifest.ttl new file mode 100644 index 00000000..faae5857 --- /dev/null +++ b/test/pretty/manifest.ttl @@ -0,0 +1,121 @@ +@prefix mf: . +@prefix rdfs: . +@prefix rdft: . +@prefix serd: . + +<> + a mf:Manifest ; + rdfs:comment "Serd pretty-printing test cases" ; + mf:entries ( + <#anonymous-in-list-object> + <#anonymous-object> + <#anonymous-subject-and-object> + <#anonymous-subject> + <#empty-anonymous-object> + <#empty-list-object> + <#empty-list-subject-and-object> + <#empty-list-subject> + <#list-in-object> + <#list-object> + <#list-subject-with-extras> + <#list-subject-with-list-extras> + <#list-subject> + <#many-objects> + <#nested-list-object-with-empty-lists> + <#nested-list-object> + <#nested-list-subject> + ) . + +<#anonymous-in-list-object> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "anonymous-in-list-object" . + +<#anonymous-object> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "anonymous-object" . + +<#anonymous-subject> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "anonymous-subject" . + +<#anonymous-subject-and-object> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "anonymous-subject-and-object" . + +<#empty-anonymous-object> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "empty-anonymous-object" . + +<#empty-list-object> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "empty-list-object" . + +<#empty-list-subject> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "empty-list-subject" . + +<#empty-list-subject-and-object> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "empty-list-subject-and-object" . + +<#list-in-object> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "list-in-object" . + +<#list-object> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "list-object" . + +<#list-subject> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "list-subject" . + +<#list-subject-with-extras> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "list-subject-with-extras" . + +<#list-subject-with-list-extras> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "list-subject-with-list-extras" . + +<#many-objects> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "many-objects" . + +<#nested-list-object> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "nested-list-object" . + +<#nested-list-object-with-empty-lists> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "nested-list-object-with-empty-lists" . + +<#nested-list-subject> + a serd:TestTurtlePrint ; + mf:action ; + mf:name "nested-list-subject" . + +serd:TestTurtlePrint + a rdfs:Class ; + rdfs:comment "Tests that a Turtle document pretty-prints exactly as written." ; + rdfs:label "Turtle Pretty-Printing" ; + rdfs:subClassOf rdft:Test . + +rdft:Test + rdfs:subClassOf mf:ManifestEntry . diff --git a/test/pretty/many-objects.ttl b/test/pretty/many-objects.ttl new file mode 100644 index 00000000..534741dd --- /dev/null +++ b/test/pretty/many-objects.ttl @@ -0,0 +1,9 @@ +@prefix eg: . + +eg:s + eg:p1 "apple" , + "banana" , + "cherry" ; + eg:p2 "asparagus" , + "beet" , + "carrot" . diff --git a/test/pretty/meson.build b/test/pretty/meson.build new file mode 100644 index 00000000..634f1e0e --- /dev/null +++ b/test/pretty/meson.build @@ -0,0 +1,17 @@ +base_uri = 'http://drobilla.net/sw/serd/test/good/' + +args = [files('manifest.ttl')] + +test('pretty', + run_pretty_suite, + args: pipe_test_script_args + ['-o', meson.current_build_dir() / 'pipe'] + args, + env: test_env, + suite: ['suite', 'extra', 'pipe'], + timeout: 240) + +test('pretty', + run_pretty_suite, + args: sort_test_script_args + ['-o', meson.current_build_dir() / 'sort'] + args, + env: test_env, + suite: ['suite', 'extra', 'sort'], + timeout: 240) diff --git a/test/pretty/nested-list-object-with-empty-lists.ttl b/test/pretty/nested-list-object-with-empty-lists.ttl new file mode 100644 index 00000000..4760fd2b --- /dev/null +++ b/test/pretty/nested-list-object-with-empty-lists.ttl @@ -0,0 +1,11 @@ +@prefix eg: . + +eg:s + eg:list ( + ( + () + ) + ( + () + ) + ) . diff --git a/test/pretty/nested-list-object.ttl b/test/pretty/nested-list-object.ttl new file mode 100644 index 00000000..c4b1898f --- /dev/null +++ b/test/pretty/nested-list-object.ttl @@ -0,0 +1,13 @@ +@prefix eg: . + +eg:s + eg:list ( + ( + eg:l1e1 + eg:l1e2 + ) + ( + eg:l2e1 + eg:l2e2 + ) + ) . diff --git a/test/pretty/nested-list-subject.ttl b/test/pretty/nested-list-subject.ttl new file mode 100644 index 00000000..b32aa133 --- /dev/null +++ b/test/pretty/nested-list-subject.ttl @@ -0,0 +1,13 @@ +@prefix eg: . + +( + ( + eg:l1e1 + eg:l1e2 + ) + ( + eg:l2e1 + eg:l2e2 + ) +) + a eg:ExampleList . -- cgit v1.2.1