From 1fd33e0a85bdf6bcc4f8138940462c4a4a391175 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 14 Oct 2019 23:26:41 +0200 Subject: Add support for converting literals to canonical form --- test/meson.build | 7 +++ test/normalise/bad-boolean.ttl | 5 +++ test/normalise/bad-decimal-leading.ttl | 4 ++ test/normalise/bad-decimal-trailing.ttl | 4 ++ test/normalise/bad-empty-boolean.ttl | 5 +++ test/normalise/bad-integer-leading.ttl | 4 ++ test/normalise/bad-integer-trailing.ttl | 4 ++ test/normalise/manifest.ttl | 60 ++++++++++++++++++++++++++ test/normalise/test-normalise.nt | 69 ++++++++++++++++++++++++++++++ test/normalise/test-normalise.ttl | 75 +++++++++++++++++++++++++++++++++ 10 files changed, 237 insertions(+) create mode 100644 test/normalise/bad-boolean.ttl create mode 100644 test/normalise/bad-decimal-leading.ttl create mode 100644 test/normalise/bad-decimal-trailing.ttl create mode 100644 test/normalise/bad-empty-boolean.ttl create mode 100644 test/normalise/bad-integer-leading.ttl create mode 100644 test/normalise/bad-integer-trailing.ttl create mode 100644 test/normalise/manifest.ttl create mode 100644 test/normalise/test-normalise.nt create mode 100644 test/normalise/test-normalise.ttl (limited to 'test') diff --git a/test/meson.build b/test/meson.build index 87b77334..d364b4f2 100644 --- a/test/meson.build +++ b/test/meson.build @@ -173,6 +173,13 @@ if get_option('utils') suite: ['rdf', 'serd'], timeout: 240) + manifest = files('normalise' / 'manifest.ttl') + base_uri = serd_base + 'normalise' + '/' + test('normalise', run_test_suite, + args: script_args + [manifest, base_uri, '--', '-C'], + suite: ['rdf', 'serd'], + timeout: 240) + ### Run the lax suite with lax parsing enabled as well manifest = files('lax/manifest.ttl') base_uri = serd_base + 'lax/' diff --git a/test/normalise/bad-boolean.ttl b/test/normalise/bad-boolean.ttl new file mode 100644 index 00000000..c4fc3eb5 --- /dev/null +++ b/test/normalise/bad-boolean.ttl @@ -0,0 +1,5 @@ +@base . +@prefix xsd: . + +[] " ja "^^xsd:boolean . + diff --git a/test/normalise/bad-decimal-leading.ttl b/test/normalise/bad-decimal-leading.ttl new file mode 100644 index 00000000..0d18eac7 --- /dev/null +++ b/test/normalise/bad-decimal-leading.ttl @@ -0,0 +1,4 @@ +@base . +@prefix xsd: . + +[] " junk 1234.5678 "^^xsd:decimal . diff --git a/test/normalise/bad-decimal-trailing.ttl b/test/normalise/bad-decimal-trailing.ttl new file mode 100644 index 00000000..10882ef5 --- /dev/null +++ b/test/normalise/bad-decimal-trailing.ttl @@ -0,0 +1,4 @@ +@base . +@prefix xsd: . + +[] " 1234.5678 junk "^^xsd:decimal . diff --git a/test/normalise/bad-empty-boolean.ttl b/test/normalise/bad-empty-boolean.ttl new file mode 100644 index 00000000..9a390c46 --- /dev/null +++ b/test/normalise/bad-empty-boolean.ttl @@ -0,0 +1,5 @@ +@base . +@prefix xsd: . + +[] ""^^xsd:boolean . + diff --git a/test/normalise/bad-integer-leading.ttl b/test/normalise/bad-integer-leading.ttl new file mode 100644 index 00000000..80c1a6af --- /dev/null +++ b/test/normalise/bad-integer-leading.ttl @@ -0,0 +1,4 @@ +@base . +@prefix xsd: . + +[] " junk 987654321 "^^xsd:integer . diff --git a/test/normalise/bad-integer-trailing.ttl b/test/normalise/bad-integer-trailing.ttl new file mode 100644 index 00000000..a94a9ec4 --- /dev/null +++ b/test/normalise/bad-integer-trailing.ttl @@ -0,0 +1,4 @@ +@base . +@prefix xsd: . + +[] " 987654321 junk "^^xsd:integer . diff --git a/test/normalise/manifest.ttl b/test/normalise/manifest.ttl new file mode 100644 index 00000000..a76f589d --- /dev/null +++ b/test/normalise/manifest.ttl @@ -0,0 +1,60 @@ +@prefix mf: . +@prefix rdf: . +@prefix rdfs: . +@prefix rdft: . + +<> + rdf:type mf:Manifest ; + rdfs:comment "Serd normalisation test cases" ; + mf:entries ( + <#bad-boolean> + <#bad-decimal-leading> + <#bad-decimal-trailing> + <#bad-empty-boolean> + <#bad-integer-leading> + <#bad-integer-trailing> + <#test-normalise> + ) . + +<#bad-boolean> + rdf:type rdft:TestTurtleNegativeEval ; + mf:name "bad-boolean" ; + rdfs:comment "Invalid xsd::boolean syntax" ; + mf:action . + +<#bad-decimal-leading> + rdf:type rdft:TestTurtleNegativeEval ; + mf:name "bad-decimal-leading" ; + rdfs:comment "Invalid xsd::decimal syntax (leading garbage)" ; + mf:action . + +<#bad-decimal-trailing> + rdf:type rdft:TestTurtleNegativeEval ; + mf:name "bad-decimal-trailing" ; + rdfs:comment "Invalid xsd::decimal syntax (trailing garbage)" ; + mf:action . + +<#bad-empty-boolean> + rdf:type rdft:TestTurtleNegativeEval ; + mf:name "bad-empty-boolean" ; + rdfs:comment "Invalid xsd::boolean syntax (no value)" ; + mf:action . + +<#bad-integer-leading> + rdf:type rdft:TestTurtleNegativeEval ; + mf:name "bad-integer-leading" ; + rdfs:comment "Invalid xsd::integer syntax (leading garbage)" ; + mf:action . + +<#bad-integer-trailing> + rdf:type rdft:TestTurtleNegativeEval ; + mf:name "bad-integer-trailing" ; + rdfs:comment "Invalid xsd::integer syntax (trailing garbage)" ; + mf:action . + +<#test-normalise> + rdf:type rdft:TestTurtleEval ; + mf:name "test-normalise" ; + mf:action ; + mf:result . + diff --git a/test/normalise/test-normalise.nt b/test/normalise/test-normalise.nt new file mode 100644 index 00000000..ed32a059 --- /dev/null +++ b/test/normalise/test-normalise.nt @@ -0,0 +1,69 @@ +_:b1 "false"^^ . +_:b1 "false"^^ . +_:b1 "true"^^ . +_:b1 "true"^^ . +_:b1 "1.0E2"^^ . +_:b1 "-1.0E2"^^ . +_:b1 "1.0E3"^^ . +_:b1 "-1.0E3"^^ . +_:b1 "9223372036854775807"^^ . +_:b1 "-9223372036854775808"^^ . +_:b1 "2147483647"^^ . +_:b1 "-2147483648"^^ . +_:b1 "32767"^^ . +_:b1 "-32768"^^ . +_:b1 "127"^^ . +_:b1 "-128"^^ . +_:b1 "1"^^ . +_:b1 "18446744073709551615"^^ . +_:b1 "1"^^ . +_:b1 "4294967295"^^ . +_:b1 "1"^^ . +_:b1 "65535"^^ . +_:b1 "1"^^ . +_:b1 "255"^^ . +_:b1 "0.0"^^ . +_:b1 "0.0"^^ . +_:b1 "-0.0"^^ . +_:b1 "36893488147419103232.0"^^ . +_:b1 "36893488147419103232.0"^^ . +_:b1 "36893488147419103232.0"^^ . +_:b1 "36893488147419103232.0"^^ . +_:b1 "36893488147419103232.0"^^ . +_:b1 "36893488147419103232.0"^^ . +_:b1 "36893488147419103232.123"^^ . +_:b1 "-36893488147419103232.0"^^ . +_:b1 "-36893488147419103232.0"^^ . +_:b1 "-36893488147419103232.0"^^ . +_:b1 "-36893488147419103232.0"^^ . +_:b1 "-36893488147419103232.123"^^ . +_:b1 "0.123"^^ . +_:b1 "0.123"^^ . +_:b1 "0.123"^^ . +_:b1 "0.123"^^ . +_:b1 "-0.123"^^ . +_:b1 "-0.123"^^ . +_:b1 "36893488147419103232"^^ . +_:b1 "36893488147419103232"^^ . +_:b1 "36893488147419103232"^^ . +_:b1 "36893488147419103232"^^ . +_:b1 "-36893488147419103232"^^ . +_:b1 "-36893488147419103232"^^ . +_:b1 "0"^^ . +_:b1 "-36893488147419103232"^^ . +_:b1 "-1"^^ . +_:b1 "-36893488147419103232"^^ . +_:b1 "0"^^ . +_:b1 "36893488147419103232"^^ . +_:b1 "1"^^ . +_:b1 "36893488147419103232"^^ . +_:b1 "no language tag" . +_:b1 "P1Y6M"^^ . +_:b1 "12:15:01Z"^^ . +_:b1 "2004-04-12Z"^^ . +_:b1 "A1B7F080"^^ . +_:b1 "Zm9vYmF="^^ . +_:b1 "untyped" . +_:b1 . +_:b1 "notxsd"^^ . +_:b1 "unsupported"^^ . diff --git a/test/normalise/test-normalise.ttl b/test/normalise/test-normalise.ttl new file mode 100644 index 00000000..8cb3f0aa --- /dev/null +++ b/test/normalise/test-normalise.ttl @@ -0,0 +1,75 @@ +@base . +@prefix rdf: . +@prefix xsd: . + +[ + " false "^^xsd:boolean , + " 0 "^^xsd:boolean , + " true "^^xsd:boolean , + " 1 "^^xsd:boolean ; + " +0100.0 "^^xsd:float , + " -0100.0 "^^xsd:float , + " +01000.0 "^^xsd:double , + " -01000.0 "^^xsd:double ; + " +09223372036854775807 "^^xsd:long , + " -09223372036854775808 "^^xsd:long , + " +02147483647 "^^xsd:int , + " -02147483648 "^^xsd:int , + " +032767 "^^xsd:short , + " -032768 "^^xsd:short , + " +0127 "^^xsd:byte , + " -0128 "^^xsd:byte , + " 01 "^^xsd:unsignedLong , + " 018446744073709551615 "^^xsd:unsignedLong , + " 01 "^^xsd:unsignedInt , + " 04294967295 "^^xsd:unsignedInt , + " 01 "^^xsd:unsignedShort , + " 065535 "^^xsd:unsignedShort , + " 01 "^^xsd:unsignedByte , + " 0255 "^^xsd:unsignedByte ; + " 00 "^^xsd:decimal , + " +0 "^^xsd:decimal , + " -0 "^^xsd:decimal , + " 36893488147419103232 "^^xsd:decimal , + " 0036893488147419103232 "^^xsd:decimal , + " +36893488147419103232 "^^xsd:decimal , + " +0036893488147419103232 "^^xsd:decimal , + " +0036893488147419103232. "^^xsd:decimal , + " +0036893488147419103232.00 "^^xsd:decimal , + " +0036893488147419103232.12300 "^^xsd:decimal , + " -36893488147419103232 "^^xsd:decimal , + " -0036893488147419103232 "^^xsd:decimal , + " -0036893488147419103232. "^^xsd:decimal , + " -0036893488147419103232.00 "^^xsd:decimal , + " -0036893488147419103232.12300 "^^xsd:decimal , + " 00.12300 "^^xsd:decimal , + " .12300 "^^xsd:decimal , + " +.12300 "^^xsd:decimal , + " +00.12300 "^^xsd:decimal , + " -.12300 "^^xsd:decimal , + " -00.12300 "^^xsd:decimal ; + " 36893488147419103232 "^^xsd:integer , + " 0036893488147419103232 "^^xsd:integer , + " +36893488147419103232 "^^xsd:integer , + " +0036893488147419103232 "^^xsd:integer , + " -36893488147419103232 "^^xsd:integer , + " -0036893488147419103232 "^^xsd:integer , + " 00 "^^xsd:nonPositiveInteger , + " -036893488147419103232 "^^xsd:nonPositiveInteger , + " -01 "^^xsd:negativeInteger , + " -036893488147419103232 "^^xsd:negativeInteger , + " 00 "^^xsd:nonNegativeInteger , + " 036893488147419103232 "^^xsd:nonNegativeInteger , + " +01 "^^xsd:positiveInteger , + " 036893488147419103232 "^^xsd:positiveInteger ; + "no language tag"^^rdf:langString ; +