From 52be118dc7bd9b27ae41e6ebfdc96418a70483ac Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 24 May 2021 11:32:29 +0200 Subject: [PATCH] A few more tests --- .../packages/schema/test/checker.test.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/implementations/javascript/packages/schema/test/checker.test.ts b/implementations/javascript/packages/schema/test/checker.test.ts index 6db9926..6deb73d 100644 --- a/implementations/javascript/packages/schema/test/checker.test.ts +++ b/implementations/javascript/packages/schema/test/checker.test.ts @@ -16,6 +16,9 @@ describe('checker', () => { it('detects non-bijection for symbol field', () => { expect(() => readSchema('version 1 . A = .')).toThrow(/item 1 of fields of A/); }); + it('is OK with no names in simple seqof', () => { + expect(readSchema('version 1 . A = [string ...].')).not.toBeNull(); + }); }); describe('extensible record', () => { @@ -38,4 +41,23 @@ describe('checker', () => { .toThrow(/tail of fields of ExtensibleRecord/); }); }); + + describe('duplicate bindings', () => { + it('complains about duplicates in tuples', () => { + expect(() => readSchema('version 1 . A = [@a string @a string].')) + .toThrow(/duplicate binding named "a" in item 1 of A/); + }); + it('complains about duplicates in dicts', () => { + expect(() => readSchema('version 1 . A = { x: @a string , y: @a string }.')) + .toThrow(/duplicate binding named "a" in entry y in dictionary in A/); + }); + it('complains about duplicates in tuple*s', () => { + expect(() => readSchema('version 1 . A = [@a string @b string @a int @rest any ...].')) + .toThrow(/duplicate binding named "a" in item 2 of A/); + }); + it('complains about duplicates in tuple* tails', () => { + expect(() => readSchema('version 1 . A = [@a string @b string @c int @a any ...].')) + .toThrow(/duplicate binding named "a" in tail of A/); + }); + }); });