Browse Source

Don't write xsd:decimal literals to Turtle bare if they would not be read back

with the same type.

Run thru tests on manifest-based test suites.


git-svn-id: http://svn.drobilla.net/serd/trunk@428 490d8e77-9747-427b-9fa3-0b8f29cee8a0
zrythm_meson
David Robillard 10 years ago
parent
commit
1d32c6e37b
  1. 4
      NEWS
  2. 10
      src/writer.c
  3. 26
      wscript

4
NEWS

@ -1,6 +1,8 @@ @@ -1,6 +1,8 @@
serd (0.18.3) unstable;
* Support most of the latest Turtle Editor's Draft
* Support most of the latest Turtle Draft
* Don't write xsd:decimal literals to Turtle bare if they would not be read
back with the same type
* Fix possible crash in serd_writer_end_anon() when writing invalid lists
* Generate blank names like _:b1 and _:B2 not _:genid1 _:docid2
* Correctly handle posix_memalign failure

10
src/writer.c

@ -442,10 +442,18 @@ write_node(SerdWriter* writer, @@ -442,10 +442,18 @@ write_node(SerdWriter* writer,
const char* type_uri = (const char*)datatype->buf;
if (!strncmp(type_uri, NS_XSD, sizeof(NS_XSD) - 1) && (
!strcmp(type_uri + sizeof(NS_XSD) - 1, "boolean") ||
!strcmp(type_uri + sizeof(NS_XSD) - 1, "decimal") ||
!strcmp(type_uri + sizeof(NS_XSD) - 1, "integer"))) {
sink(node->buf, node->n_bytes, writer);
break;
} else if (!strcmp(type_uri + sizeof(NS_XSD) - 1, "decimal") &&
strchr((const char*)node->buf, '.') &&
node->buf[node->n_bytes - 1] != '.') {
/* xsd:decimal literals without trailing digits, e.g. "5.", can
not be written bare in Turtle. We could add a 0 which is
prettier, but changes the text and breaks round tripping.
*/
sink(node->buf, node->n_bytes, writer);
break;
}
}
if (writer->syntax != SERD_NTRIPLES

26
wscript

@ -282,19 +282,18 @@ def earl_assertion(test, passed, asserter): @@ -282,19 +282,18 @@ def earl_assertion(test, passed, asserter):
"earl:passed" if passed else "earl:failed",
datetime.datetime.now().replace(microsecond=0).isoformat())
def test_thru(ctx, base, path, flags):
in_filename = os.path.join(ctx.path.abspath(), path)
out_filename = path + '.thru'
check_filename = in_filename.replace('.ttl', '.nt')
def test_thru(ctx, base, in_filename, check_filename, flags):
out_filename = in_filename + '.thru'
command = ('%s %s -i ntriples -o turtle -p foo "%s" "%s"'
'| %s -i turtle -o ntriples -c foo - "%s" > %s') % (
command = ('%s %s -i ntriples -o turtle -p foo "%s" "%s" | '
'%s -i turtle -o ntriples -c foo - "%s" > %s') % (
'serdi_static', flags.ljust(5),
in_filename, base,
'serdi_static', base, out_filename)
passed = autowaf.run_test(ctx, APPNAME, command, 0, name=out_filename)
if not passed:
Logs.pprint('RED', '** Failed command: %s' % command)
return False
if not os.access(out_filename, os.F_OK):
@ -302,7 +301,7 @@ def test_thru(ctx, base, path, flags): @@ -302,7 +301,7 @@ def test_thru(ctx, base, path, flags):
elif not file_equals(check_filename, out_filename, '_:docid', '_:genid'):
Logs.pprint('RED', 'FAIL: %s != %s' % (out_filename, check_filename))
else:
Logs.pprint('GREEN', '** Pass %s == %s' % (out_filename, check_filename))
#Logs.pprint('GREEN', '** Pass %s == %s' % (out_filename, check_filename))
return True
return False
@ -358,17 +357,21 @@ def test_manifest(ctx, srcdir, testdir, report, test_base, parse_base): @@ -358,17 +357,21 @@ def test_manifest(ctx, srcdir, testdir, report, test_base, parse_base):
passed = run_test(action_node, 0)
if passed:
action = os.path.join(srcdir, 'tests', testdir, action_node)
output = os.path.join('tests', testdir, action_node + '.out')
result = os.path.join(srcdir, 'tests', testdir, result_node)
rel = os.path.relpath(action, os.path.join(srcdir, 'tests', testdir))
if not os.access(output, os.F_OK):
passed = False
Logs.pprint('RED', 'FAIL: %s output %s is missing' % (name, output))
elif not file_equals(result, output):
passed = False
Logs.pprint('RED', 'FAIL: %s\n != %s' % (os.path.abspath(output), result))
Logs.pprint('RED', 'FAIL: %s != %s' % (os.path.abspath(output), result))
else:
Logs.pprint('GREEN', '** Pass %s' % output)
test_thru(ctx, parse_base + rel, action, result, "")
report.write(earl_assertion(test, passed, asserter))
def test(ctx):
@ -492,8 +495,11 @@ def test(ctx): @@ -492,8 +495,11 @@ def test(ctx):
if (num % 7 == 0):
flags += ' -e'
path = os.path.join('tests', tdir, test)
test_thru(ctx, test_base(test), path, flags)
path = os.path.join('tests', tdir, test)
in_filename = os.path.join(ctx.path.abspath(), path)
check_filename = in_filename.replace('.ttl', '.nt')
test_thru(ctx, test_base(test), in_filename, check_filename, flags)
try:
report = open('earl.ttl', 'w')

Loading…
Cancel
Save