@@ -5,7 +5,7 @@ local msgpack = require('msgpack')
55
66local test = tap .test (' api-tests' )
77
8- test :plan (27 )
8+ test :plan (35 )
99
1010-- nested records, union, reference to earlier declared type
1111local foobar_decl = {
@@ -37,6 +37,17 @@ for _, type in ipairs(
3737 test :is_deeply (schema .export (res [2 ]), type , ' schema normalization ' .. type )
3838end
3939
40+ -- nullable scalar export
41+ for _ , type in ipairs (
42+ {
43+ " int*" , " string*" , " null*" , " boolean*" , " long*" ,
44+ " float" , " double*" , " bytes*"
45+ }) do
46+ res = {schema .create ({type = type })}
47+ test :is_deeply (schema .export (res [2 ]), type ,
48+ ' nullable scalar normalization ' .. type )
49+ end
50+
4051-- fingerprint tests
4152local fingerprint_testcases = {
4253 {
@@ -266,35 +277,18 @@ local nullable_orig = [[ {
266277 {"name": "v2", "type": "string*"} ] } },
267278 { "name": "r2", "type": "tr1*"},
268279 { "name": "dummy", "type": {
269- "name": "td", "type": "array", "items": "int" }},
280+ "type": "array", "items": "int" }},
270281 { "name": "r3", "type": {
271282 "name": "tr2", "type": "record*", "fields": [
272283 {"name": "v1", "type": "string"} ,
273284 {"name": "v2", "type": "int*"} ] } },
274285 { "name": "r4", "type": "tr2" }]
275286}]]
276-
277- -- TODO: the `nullable_orig` should be used after #74
278- local nullable_exported = [[
279- {"type":"record","fields":
280- [{"name":"r1","type":
281- {"type":"record","fields":
282- [{"name":"v1","type":"int"},
283- {"name":"v2","type":{"type":"string*"}}],
284- "name":"tr1"}},
285- {"name":"r2","type":"tr1*"},
286- {"name":"dummy","type":{"type":"array","items":"int"}},
287- {"name":"r3","type":
288- {"type":"record*","name":"tr2","fields":
289- [{"name":"v1","type":"string"},
290- {"name":"v2","type":{"type":"int*"}}]}},
291- {"name":"r4","type":"tr2"}],
292- "name":"outer"}
293- ]]
294- res = {schema .create (json .decode (nullable_orig ))}
287+ nullable_orig = json .decode (nullable_orig )
288+ res = {schema .create (nullable_orig )}
295289test :is (res [1 ], true , " Schema created successfully" )
296290res = schema .export (res [2 ])
297- test :is_deeply (res , json . decode ( nullable_exported ) , " Exported schema is valid." )
291+ test :is_deeply (res , nullable_orig , " Exported schema is valid." )
298292
299293-- check if nullable reference is not exported as a definition
300294local nullable_reference = {
0 commit comments