From 9b0e92e8729e660bfdcf02a3169b9a4b829762a4 Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Fri, 18 Mar 2022 14:24:17 +0000 Subject: [PATCH 1/9] revise existing tests to match #311 (subtype checking only for reference types) --- test/construct.test.did | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/construct.test.did b/test/construct.test.did index 397da032a..ca4bd87ff 100644 --- a/test/construct.test.did +++ b/test/construct.test.did @@ -54,7 +54,7 @@ assert blob "DIDL\00\00" == "(null)" : (Opt) "op // vector assert blob "DIDL\01\6d\7c\01\00\00" == "(vec {})" : (vec int) "vec: empty"; -assert blob "DIDL\01\6d\7c\01\00\00" !: (vec int8) "vec: non subtype empty"; +assert blob "DIDL\01\6d\7c\01\00\00" : (vec int8) "vec: non subtype empty"; assert blob "DIDL\01\6d\7c\01\00\02\01\02" == "(vec { 1; 2 })" : (vec int) "vec"; assert blob "DIDL\01\6d\7b\01\00\02\01\02" == "(blob \"\\01\\02\")" : (vec nat8) "vec: blob"; assert blob "DIDL\01\6d\00\01\00\00" == "(vec {})" : (Vec) "vec: recursive vector"; @@ -139,10 +139,10 @@ assert "(variant {})" ! assert blob "DIDL\01\6b\00\01\00" !: (variant {}) "variant: no empty value"; assert blob "DIDL\01\6b\01\00\7f\01\00\00" == "(variant {0})" : (variant {0}) "variant: numbered field"; assert blob "DIDL\01\6b\01\00\7f\01\00\00\2a" !: (variant {0:int}) "variant: type mismatch"; -assert blob "DIDL\01\6b\02\00\7f\01\7c\01\00\01\2a" !: (variant {0:int; 1:int}) "variant: type mismatch in unused tag"; +assert blob "DIDL\01\6b\02\00\7f\01\7c\01\00\01\2a" : (variant {0:int; 1:int}) "variant: type mismatch in unused tag"; assert blob "DIDL\01\6b\01\00\7f\01\00\00" == "(variant {0})" : (variant {0;1}) "variant: ignore field"; -assert blob "DIDL\01\6b\02\00\7f\01\7f\01\00\00" !: (variant {0}) "variant {0;1} !<: variant {0}"; -assert blob "DIDL\01\6b\02\00\7f\01\7f\01\00\00" == "(null)" : (opt variant {0}) "variant {0;1} <: opt variant {0}"; +assert blob "DIDL\01\6b\02\00\7f\01\7f\01\00\00" : (variant {0}) "variant {0;1} <: variant {0}"; +assert blob "DIDL\01\6b\02\00\7f\01\7f\01\00\00" == "(variant {0})" : (opt variant {0}) "variant {0;1} <: opt variant {0}"; assert blob "DIDL\01\6b\02\00\7f\01\7f\01\00\01" == "(variant {1})" : (variant {0;1;2}) "variant: change index"; assert blob "DIDL\01\6b\01\00\7f\01\00\00" !: (variant {1}) "variant: missing field"; assert blob "DIDL\01\6b\01\00\7f\01\00\01" !: (variant {0}) "variant: index out of range"; From 6976902ac04ae92cb67542bcfcd80f24557517b9 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Fri, 8 Apr 2022 17:15:48 +0200 Subject: [PATCH 2/9] More test cases, new file for subtype tests --- test/construct.test.did | 2 +- test/prim.test.did | 14 +++++++++++--- test/subtypes.test.did | 43 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 test/subtypes.test.did diff --git a/test/construct.test.did b/test/construct.test.did index ca4bd87ff..9fa6b992b 100644 --- a/test/construct.test.did +++ b/test/construct.test.did @@ -188,7 +188,7 @@ assert blob "DIDL\02\6b\02\d1\a7\cf\02\7f\f1\f3\92\8e\04\01\6c\02\a0\d2\ac\a8\04 == "(variant { cons = record { head = 1; tail = variant { cons = record { head = 2; tail = variant { nil } } } } })" : (VariantList) "variant: list"; assert blob "DIDL\02\6b\02\d1\a7\cf\02\7f\f1\f3\92\8e\04\01\6c\02\a0\d2\ac\a8\04\7c\90\ed\da\e7\04\00\01\00\00" - == "(variant {nil}, null, null, null, null)" : (VariantList, opt VariantList, null, reserved, opt int) "variant: extra args"; + == "(variant {nil}, null, null, null, null)" : (VariantList, opt VariantList, opt empty, reserved, opt int) "variant: extra args"; assert blob "DIDL\02\6b\02\d1\a7\cf\02\7f\f1\f3\92\8e\04\01\6c\02\a0\d2\ac\a8\04\7c\90\ed\da\e7\04\00\01\00\00" !: (VariantList, opt int, vec int) "non-null extra args"; diff --git a/test/prim.test.did b/test/prim.test.did index 91607aa1d..74f751388 100644 --- a/test/prim.test.did +++ b/test/prim.test.did @@ -1,7 +1,7 @@ /* Encoding tests for primitive types -Corresponding to spec version version 0.1.3 +Corresponding to spec version version 0.1.4 */ // fundamentally wrong @@ -19,11 +19,19 @@ assert blob "DIDL\00\01\7f" : () "Additional parameters are ignored"; assert blob "DIDL\00\01\6e" !: () "Not a primitive type"; assert blob "DIDL\00\01\5e" !: () "Out of range type"; +// Missing arguments +assert blob "DIDL\00\00" !: (nat) "missing argument: nat fails"; +assert blob "DIDL\00\00" !: (empty) "missing argument: empty fails"; +assert blob "DIDL\00\00" !: (null) "missing argument: null fails"; +assert blob "DIDL\00\00" == "(null)" : (opt empty) "missing argument: opt empty"; +assert blob "DIDL\00\00" == "(null)" : (opt null) "missing argument: opt null"; +assert blob "DIDL\00\00" == "(null)" : (opt nat) "missing argument: opt nat"; +assert blob "DIDL\00\00" == blob "DIDL\00\01\70" : (reserved) "missing argument: reserved"; + // primitive types assert blob "DIDL\00\01\7f" : (null); assert blob "DIDL\00\01\7e" !: (null) "wrong type"; assert blob "DIDL\00\01\7f\00" !: (null) "null: too long"; -assert blob "DIDL\00\00" : (null) "null: extra null values"; assert blob "DIDL\00\01\7e\00" == "(false)" : (bool) "bool: false"; assert blob "DIDL\00\01\7e\01" == "(true)" : (bool) "bool: true"; @@ -180,12 +188,12 @@ assert blob "DIDL\00\01\70" == blob "DIDL\00\01\7f" : (reserved) "reser assert blob "DIDL\00\01\70" == blob "DIDL\00\01\7e\01" : (reserved) "reserved from bool"; assert blob "DIDL\00\01\70" == blob "DIDL\00\01\7d\80\01" : (reserved) "reserved from nat"; assert blob "DIDL\00\01\70" == blob "DIDL\00\01\71\06Motoko" : (reserved) "reserved from text"; -assert blob "DIDL\00\00" : (reserved) "reserved extra value"; assert blob "DIDL\00\01\71\05Motoko" !: (reserved) "reserved from too short text"; assert blob "DIDL\00\01\71\03\e2\28\a1" !: (reserved) "reserved from invalid utf8 text"; assert blob "DIDL\00\01\6f" !: (empty) "cannot decode empty type"; assert blob "DIDL\01\6e\6f\01\00\00" == "(null)" : (opt empty) "okay to decode non-empty value"; + assert blob "DIDL\00\0a\7f\7e\7d\7c\7f\70\7f\7b\7a\79\01\2a\2a\2a\2a\00\2a\00\00\00" == "(null, true, 42, 42, null, null, null, 42, 42, 42)" : (null, bool, nat, int, null, reserved, null, nat8, nat16, nat32) "multiple arguments"; diff --git a/test/subtypes.test.did b/test/subtypes.test.did new file mode 100644 index 000000000..126a2c903 --- /dev/null +++ b/test/subtypes.test.did @@ -0,0 +1,43 @@ +/* +Encoding tests for subtype tests in decoders + +Corresponding to spec version version 0.1.4 + +This test file contains tests for the subtype check that decoders are expected +to perform upon references. + +The shortest way to trigger a test for `t1 <: t2` is to pass `(func () -> (t1))` +and decode at type `(opt func () -> (t2))`, and check if the result is a +`reference` or `null`. + +The patterns are hence + +assert blob "DIDL\01\6a\00\01XX00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (t2)) "t1 <: t2"; + +assert blob "DIDL\01\6a\00\01XX\00\01\00\01\01\00\00" + == "(null)" : (opt func () -> (t2)) "t1 (null)) "null <: null"; +assert blob "DIDL\01\6a\00\01\7e\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (bool)) "bool <: bool"; +assert blob "DIDL\01\6a\00\01\7d\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (nat)) "nat <: nat"; +assert blob "DIDL\01\6a\00\01\7c\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (int)) "int <: int"; + +// more basic cases +assert blob "DIDL\01\6a\00\01\7d\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (int)) "nat <: int"; +assert blob "DIDL\01\6a\00\01\7f\00\01\00\01\01\00\00" + == "(null)" : (opt func () -> (nat)) "int (nat8)) "nat (nat)) "nat8 Date: Fri, 8 Apr 2022 18:05:21 +0200 Subject: [PATCH 3/9] Many more tests --- test/subtypes.test.did | 80 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/test/subtypes.test.did b/test/subtypes.test.did index 126a2c903..dc8ae67b4 100644 --- a/test/subtypes.test.did +++ b/test/subtypes.test.did @@ -10,15 +10,21 @@ The shortest way to trigger a test for `t1 <: t2` is to pass `(func () -> (t1))` and decode at type `(opt func () -> (t2))`, and check if the result is a `reference` or `null`. -The patterns are hence +The patterns idioms here are thus assert blob "DIDL\01\6a\00\01XX00\01\00\01\01\00\00" == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (t2)) "t1 <: t2"; - assert blob "DIDL\01\6a\00\01XX\00\01\00\01\01\00\00" == "(null)" : (opt func () -> (t2)) "t1 (t2)) "t1 <: t2"; +assert blob "DIDL\02\6a\00\01\01\00XX\01\00\01\01\00\00" + == "(null)" : (opt func () -> (t2)) "t1 (nat)) "nat8 (opt bool)) "nat <: opt bool"; +assert blob "DIDL\02\6a\00\01\01\00\6e\7e\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (opt bool)) "opt bool <: opt bool"; +assert blob "DIDL\01\6a\00\01\7e\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (opt bool)) "bool <: opt bool"; +assert blob "DIDL\02\6a\00\01\01\00\6e\01\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (opt opt nat)) "µ opt <: opt opt nat"; + +// optional record fields +assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (record {})) "record {} <: record {}"; +assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (record { a : opt empty })) "record {} <: record { a : opt empty }"; +assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (record { a : opt null })) "record {} <: record { a : opt null }"; +assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (record { a : reserved })) "record {} <: record { a : reserved }"; +assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\00" + == "(null)" : (opt func () -> (record { a : empty })) "record {} (record { a : nat })) "record {} (record { a : null })) "record {} (func () -> ())) "func () -> () <: func () -> ()"; +assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (func () -> (opt empty))) "func () -> () <: func () -> (opt empty)"; +assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (func () -> (opt null))) "func () -> () <: func () -> (opt null)"; +assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (func () -> (reserved))) "func () -> () <: func () -> (reserved)"; +assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\00" + == "(null)" : (opt func () -> (func () -> (empty))) "func () -> () (empty)"; +assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\00" + == "(null)" : (opt func () -> (func () -> (nat))) "func () -> () (nat)"; +assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\00" + == "(null)" : (opt func () -> (func () -> (null))) "func () -> () (null)"; + +// optional func arguments +assert blob "DIDL\03\6a\00\01\01\00\6a\01\02\00\00\6e\6f\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (func () -> ())) "func (opt empty) -> () <: func () -> ()"; +assert blob "DIDL\03\6a\00\01\01\00\6a\01\02\00\00\6e\7f\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (func () -> ())) "func (opt null) -> () <: func () -> ()"; +assert blob "DIDL\02\6a\00\01\01\00\6a\01\70\00\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (func () -> ())) "func (reserved) -> () <: func () -> ()"; +assert blob "DIDL\02\6a\00\01\01\00\6a\01\6f\00\00\01\00\01\01\00\00" + == "(null)" : (opt func () -> (func () -> ())) "func (empty) -> () ()"; +assert blob "DIDL\02\6a\00\01\01\00\6a\01\7d\00\00\01\00\01\01\00\00" + == "(null)" : (opt func () -> (func () -> ())) "func (nat) -> () ()"; +assert blob "DIDL\02\6a\00\01\01\00\6a\01\7f\00\00\01\00\01\01\00\00" + == "(null)" : (opt func () -> (func () -> ())) "func (null) -> () ()"; + +// variants +assert blob "DIDL\02\6a\00\01\01\00\6b\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (variant {})) "variant {} <: variant {}"; +assert blob "DIDL\02\6a\00\01\01\00\6b\00\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (variant {0 : nat})) "variant {} <: variant {0 : nat}"; +assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\7d\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (variant {0 : nat})) "variant {0 : nat} <: variant {0 : nat}"; +assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\7e\01\00\01\01\00\00" + == "(null)" : (opt func () -> (variant {0 : nat})) "variant {0 : bool} (variant {1 : bool})) "variant {0 : bool} Date: Fri, 8 Apr 2022 19:08:22 +0200 Subject: [PATCH 4/9] Tests about infinite types --- test/subtypes.test.did | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/subtypes.test.did b/test/subtypes.test.did index dc8ae67b4..ef2b80f62 100644 --- a/test/subtypes.test.did +++ b/test/subtypes.test.did @@ -27,6 +27,10 @@ assert blob "DIDL\02\6a\00\01\01\00XX\01\00\01\01\00\00" where XX is a type entry table for a non-primitive type t1 */ +type Vec = vec Vec; +type EmptyRecord = record { 0 : EmptyRecord }; +type EmptyVariant = variant { 0: EmptyVariant }; + // some reflexive cases assert blob "DIDL\01\6a\00\01\7f\00\01\00\01\01\00\00" == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (null)) "null <: null"; @@ -115,3 +119,38 @@ assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\7e\01\00\01\01\00\00" assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\7e\01\00\01\01\00\00" == "(null)" : (opt func () -> (variant {1 : bool})) "variant {0 : bool} (EmptyRecord)) "(µ record) <: (µ record)"; +assert blob "DIDL\02\6a\00\01\01\00\6c\01\00\01\01\00\01\01\00\00" + == "(null)" : (opt func () -> (empty)) "(µ record) (EmptyRecord)) "empty <: (µ record)"; +assert blob "DIDL\02\6a\00\01\01\00\6c\01\00\01\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (record {EmptyRecord})) "(µ record) <: record {µ record}"; +assert blob "DIDL\03\6a\00\01\01\00\6c\01\00\02\6c\01\00\02\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (EmptyRecord)) "record {µ record} <: (µ record)"; + +assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\01\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (EmptyVariant)) "(µ variant) <: (µ variant)"; +assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\01\01\00\01\01\00\00" + == "(null)" : (opt func () -> (empty)) "(µ variant) (EmptyVariant)) "empty <: (µ variant)"; +assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\01\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (variant {0 : EmptyVariant})) "(µ variant) <: variant {µ variant}"; +assert blob "DIDL\03\6a\00\01\01\00\6b\01\00\02\6b\01\00\02\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (EmptyVariant)) "variant {µ variant} <: (µ variant)"; + +assert blob "DIDL\02\6a\00\01\01\00\6d\01\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (Vec)) "(µ vec) <: (µ vec)"; +assert blob "DIDL\02\6a\00\01\01\00\6d\01\01\00\01\01\00\00" + == "(null)" : (opt func () -> (empty)) "(µ vec) (Vec)) "empty <: (µ vec)"; +assert blob "DIDL\02\6a\00\01\01\00\6d\01\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (vec Vec)) "(µ vec) <: vec {µ vec}"; +assert blob "DIDL\03\6a\00\01\01\00\6d\02\6d\02\01\00\01\01\00\00" + == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (Vec)) "vec {µ vec} <: (µ vec)"; From 5e8c75215342ec1bbee90912c200a81bdf5f5505 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Sat, 9 Apr 2022 14:22:52 +0200 Subject: [PATCH 5/9] Use method name "m" to work around https://github.com/dfinity/motoko/issues/1668 --- test/subtypes.test.did | 190 ++++++++++++++++++++--------------------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/test/subtypes.test.did b/test/subtypes.test.did index ef2b80f62..052d863ae 100644 --- a/test/subtypes.test.did +++ b/test/subtypes.test.did @@ -12,16 +12,16 @@ and decode at type `(opt func () -> (t2))`, and check if the result is a The patterns idioms here are thus -assert blob "DIDL\01\6a\00\01XX00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (t2)) "t1 <: t2"; -assert blob "DIDL\01\6a\00\01XX\00\01\00\01\01\00\00" +assert blob "DIDL\01\6a\00\01XX00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (t2)) "t1 <: t2"; +assert blob "DIDL\01\6a\00\01XX\00\01\00\01\01\00\01m" == "(null)" : (opt func () -> (t2)) "t1 (t2)) "t1 <: t2"; -assert blob "DIDL\02\6a\00\01\01\00XX\01\00\01\01\00\00" +assert blob "DIDL\02\6a\00\01\01\00XX\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (t2)) "t1 <: t2"; +assert blob "DIDL\02\6a\00\01\01\00XX\01\00\01\01\00\01m" == "(null)" : (opt func () -> (t2)) "t1 (null)) "null <: null"; -assert blob "DIDL\01\6a\00\01\7e\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (bool)) "bool <: bool"; -assert blob "DIDL\01\6a\00\01\7d\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (nat)) "nat <: nat"; -assert blob "DIDL\01\6a\00\01\7c\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (int)) "int <: int"; +assert blob "DIDL\01\6a\00\01\7f\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (null)) "null <: null"; +assert blob "DIDL\01\6a\00\01\7e\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (bool)) "bool <: bool"; +assert blob "DIDL\01\6a\00\01\7d\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (nat)) "nat <: nat"; +assert blob "DIDL\01\6a\00\01\7c\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (int)) "int <: int"; // more basic cases -assert blob "DIDL\01\6a\00\01\7d\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (int)) "nat <: int"; -assert blob "DIDL\01\6a\00\01\7f\00\01\00\01\01\00\00" +assert blob "DIDL\01\6a\00\01\7d\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (int)) "nat <: int"; +assert blob "DIDL\01\6a\00\01\7f\00\01\00\01\01\00\01m" == "(null)" : (opt func () -> (nat)) "int (nat8)) "nat (nat)) "nat8 (opt bool)) "nat <: opt bool"; -assert blob "DIDL\02\6a\00\01\01\00\6e\7e\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (opt bool)) "opt bool <: opt bool"; -assert blob "DIDL\01\6a\00\01\7e\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (opt bool)) "bool <: opt bool"; -assert blob "DIDL\02\6a\00\01\01\00\6e\01\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (opt opt nat)) "µ opt <: opt opt nat"; +assert blob "DIDL\01\6a\00\01\7d\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (opt bool)) "nat <: opt bool"; +assert blob "DIDL\02\6a\00\01\01\00\6e\7e\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (opt bool)) "opt bool <: opt bool"; +assert blob "DIDL\01\6a\00\01\7e\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (opt bool)) "bool <: opt bool"; +assert blob "DIDL\02\6a\00\01\01\00\6e\01\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (opt opt nat)) "µ opt <: opt opt nat"; // optional record fields -assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (record {})) "record {} <: record {}"; -assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (record { a : opt empty })) "record {} <: record { a : opt empty }"; -assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (record { a : opt null })) "record {} <: record { a : opt null }"; -assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (record { a : reserved })) "record {} <: record { a : reserved }"; -assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\00" +assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (record {})) "record {} <: record {}"; +assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (record { a : opt empty })) "record {} <: record { a : opt empty }"; +assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (record { a : opt null })) "record {} <: record { a : opt null }"; +assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (record { a : reserved })) "record {} <: record { a : reserved }"; +assert blob "DIDL\02\6a\00\01\01\00\6c\00\01\00\01\01\00\01m" == "(null)" : (opt func () -> (record { a : empty })) "record {} (record { a : nat })) "record {} (record { a : null })) "record {} (func () -> ())) "func () -> () <: func () -> ()"; -assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (func () -> (opt empty))) "func () -> () <: func () -> (opt empty)"; -assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (func () -> (opt null))) "func () -> () <: func () -> (opt null)"; -assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (func () -> (reserved))) "func () -> () <: func () -> (reserved)"; -assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\00" +assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (func () -> ())) "func () -> () <: func () -> ()"; +assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (func () -> (opt empty))) "func () -> () <: func () -> (opt empty)"; +assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (func () -> (opt null))) "func () -> () <: func () -> (opt null)"; +assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (func () -> (reserved))) "func () -> () <: func () -> (reserved)"; +assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\01m" == "(null)" : (opt func () -> (func () -> (empty))) "func () -> () (empty)"; -assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\00" +assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\01m" == "(null)" : (opt func () -> (func () -> (nat))) "func () -> () (nat)"; -assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\00" +assert blob "DIDL\02\6a\00\01\01\00\6a\00\00\00\01\00\01\01\00\01m" == "(null)" : (opt func () -> (func () -> (null))) "func () -> () (null)"; // optional func arguments -assert blob "DIDL\03\6a\00\01\01\00\6a\01\02\00\00\6e\6f\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (func () -> ())) "func (opt empty) -> () <: func () -> ()"; -assert blob "DIDL\03\6a\00\01\01\00\6a\01\02\00\00\6e\7f\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (func () -> ())) "func (opt null) -> () <: func () -> ()"; -assert blob "DIDL\02\6a\00\01\01\00\6a\01\70\00\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (func () -> ())) "func (reserved) -> () <: func () -> ()"; -assert blob "DIDL\02\6a\00\01\01\00\6a\01\6f\00\00\01\00\01\01\00\00" +assert blob "DIDL\03\6a\00\01\01\00\6a\01\02\00\00\6e\6f\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (func () -> ())) "func (opt empty) -> () <: func () -> ()"; +assert blob "DIDL\03\6a\00\01\01\00\6a\01\02\00\00\6e\7f\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (func () -> ())) "func (opt null) -> () <: func () -> ()"; +assert blob "DIDL\02\6a\00\01\01\00\6a\01\70\00\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (func () -> ())) "func (reserved) -> () <: func () -> ()"; +assert blob "DIDL\02\6a\00\01\01\00\6a\01\6f\00\00\01\00\01\01\00\01m" == "(null)" : (opt func () -> (func () -> ())) "func (empty) -> () ()"; -assert blob "DIDL\02\6a\00\01\01\00\6a\01\7d\00\00\01\00\01\01\00\00" +assert blob "DIDL\02\6a\00\01\01\00\6a\01\7d\00\00\01\00\01\01\00\01m" == "(null)" : (opt func () -> (func () -> ())) "func (nat) -> () ()"; -assert blob "DIDL\02\6a\00\01\01\00\6a\01\7f\00\00\01\00\01\01\00\00" +assert blob "DIDL\02\6a\00\01\01\00\6a\01\7f\00\00\01\00\01\01\00\01m" == "(null)" : (opt func () -> (func () -> ())) "func (null) -> () ()"; // variants -assert blob "DIDL\02\6a\00\01\01\00\6b\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (variant {})) "variant {} <: variant {}"; -assert blob "DIDL\02\6a\00\01\01\00\6b\00\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (variant {0 : nat})) "variant {} <: variant {0 : nat}"; -assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\7d\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (variant {0 : nat})) "variant {0 : nat} <: variant {0 : nat}"; -assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\7e\01\00\01\01\00\00" +assert blob "DIDL\02\6a\00\01\01\00\6b\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (variant {})) "variant {} <: variant {}"; +assert blob "DIDL\02\6a\00\01\01\00\6b\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (variant {0 : nat})) "variant {} <: variant {0 : nat}"; +assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\7d\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (variant {0 : nat})) "variant {0 : nat} <: variant {0 : nat}"; +assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\7e\01\00\01\01\00\01m" == "(null)" : (opt func () -> (variant {0 : nat})) "variant {0 : bool} (variant {1 : bool})) "variant {0 : bool} (EmptyRecord)) "(µ record) <: (µ record)"; -assert blob "DIDL\02\6a\00\01\01\00\6c\01\00\01\01\00\01\01\00\00" +assert blob "DIDL\02\6a\00\01\01\00\6c\01\00\01\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (EmptyRecord)) "(µ record) <: (µ record)"; +assert blob "DIDL\02\6a\00\01\01\00\6c\01\00\01\01\00\01\01\00\01m" == "(null)" : (opt func () -> (empty)) "(µ record) (EmptyRecord)) "empty <: (µ record)"; -assert blob "DIDL\02\6a\00\01\01\00\6c\01\00\01\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (record {EmptyRecord})) "(µ record) <: record {µ record}"; -assert blob "DIDL\03\6a\00\01\01\00\6c\01\00\02\6c\01\00\02\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (EmptyRecord)) "record {µ record} <: (µ record)"; - -assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\01\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (EmptyVariant)) "(µ variant) <: (µ variant)"; -assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\01\01\00\01\01\00\00" +assert blob "DIDL\01\6a\00\01\6f\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (EmptyRecord)) "empty <: (µ record)"; +assert blob "DIDL\02\6a\00\01\01\00\6c\01\00\01\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (record {EmptyRecord})) "(µ record) <: record {µ record}"; +assert blob "DIDL\03\6a\00\01\01\00\6c\01\00\02\6c\01\00\02\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (EmptyRecord)) "record {µ record} <: (µ record)"; + +assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\01\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (EmptyVariant)) "(µ variant) <: (µ variant)"; +assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\01\01\00\01\01\00\01m" == "(null)" : (opt func () -> (empty)) "(µ variant) (EmptyVariant)) "empty <: (µ variant)"; -assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\01\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (variant {0 : EmptyVariant})) "(µ variant) <: variant {µ variant}"; -assert blob "DIDL\03\6a\00\01\01\00\6b\01\00\02\6b\01\00\02\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (EmptyVariant)) "variant {µ variant} <: (µ variant)"; - -assert blob "DIDL\02\6a\00\01\01\00\6d\01\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (Vec)) "(µ vec) <: (µ vec)"; -assert blob "DIDL\02\6a\00\01\01\00\6d\01\01\00\01\01\00\00" +assert blob "DIDL\01\6a\00\01\6f\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (EmptyVariant)) "empty <: (µ variant)"; +assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\01\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (variant {0 : EmptyVariant})) "(µ variant) <: variant {µ variant}"; +assert blob "DIDL\03\6a\00\01\01\00\6b\01\00\02\6b\01\00\02\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (EmptyVariant)) "variant {µ variant} <: (µ variant)"; + +assert blob "DIDL\02\6a\00\01\01\00\6d\01\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (Vec)) "(µ vec) <: (µ vec)"; +assert blob "DIDL\02\6a\00\01\01\00\6d\01\01\00\01\01\00\01m" == "(null)" : (opt func () -> (empty)) "(µ vec) (Vec)) "empty <: (µ vec)"; -assert blob "DIDL\02\6a\00\01\01\00\6d\01\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (vec Vec)) "(µ vec) <: vec {µ vec}"; -assert blob "DIDL\03\6a\00\01\01\00\6d\02\6d\02\01\00\01\01\00\00" - == "(opt func \"aaaaa-aa\".\"\")" : (opt func () -> (Vec)) "vec {µ vec} <: (µ vec)"; +assert blob "DIDL\01\6a\00\01\6f\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (Vec)) "empty <: (µ vec)"; +assert blob "DIDL\02\6a\00\01\01\00\6d\01\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (vec Vec)) "(µ vec) <: vec {µ vec}"; +assert blob "DIDL\03\6a\00\01\01\00\6d\02\6d\02\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (Vec)) "vec {µ vec} <: (µ vec)"; From 0889e288c8c44ce36682ffa67df010c83e912a33 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Sat, 9 Apr 2022 14:53:43 +0200 Subject: [PATCH 6/9] A few tests with future types --- test/construct.test.did | 5 +++++ test/subtypes.test.did | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/test/construct.test.did b/test/construct.test.did index 9fa6b992b..0d3ac030f 100644 --- a/test/construct.test.did +++ b/test/construct.test.did @@ -203,3 +203,8 @@ assert blob "DIDL\07\6c\07\c3\e3\aa\02\01\d3\e3\aa\02\7e\d5\e3\aa\02\02\db\e3\aa assert blob "DIDL\07\6c\07\c3\e3\aa\02\01\d3\e3\aa\02\7e\d5\e3\aa\02\02\db\e3\aa\02\01\a2\e5\aa\02\04\bb\f1\aa\02\06\86\8e\b7\02\75\6c\02\d3\e3\aa\02\7e\86\8e\b7\02\75\6b\02\d1\a7\cf\02\7f\f1\f3\92\8e\04\03\6c\02\a0\d2\ac\a8\04\7c\90\ed\da\e7\04\02\6e\05\6c\02\a0\d2\ac\a8\04\7c\90\ed\da\e7\04\04\6b\02\d3\e3\aa\02\7f\86\8e\b7\02\7f\01\00\01\0b\00\00\00\01\00\00\0a\00\00\00\01\14\00\00\2a\00\00\00" !: (record { foo: int; new_field: bool }) "new record field"; +// Future types +// This uses 0x67 for the “future type”; bump (well, decrement) once that +// becomes a concrete future type +assert blob "DIDL\01\67\00\02\00\7e\00\00\01" == "(null, true)" : (opt empty,bool) "skipping minimal future type"; +assert blob "DIDL\01\67\03ABC\02\00\7e\05\00hello\01" == "(null,true)" : (opt empty,bool) "skipping future type with data"; diff --git a/test/subtypes.test.did b/test/subtypes.test.did index 052d863ae..acc97adeb 100644 --- a/test/subtypes.test.did +++ b/test/subtypes.test.did @@ -121,7 +121,6 @@ assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\7e\01\00\01\01\00\01m" // infinite types - assert blob "DIDL\02\6a\00\01\01\00\6c\01\00\01\01\00\01\01\00\01m" == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (EmptyRecord)) "(µ record) <: (µ record)"; assert blob "DIDL\02\6a\00\01\01\00\6c\01\00\01\01\00\01\01\00\01m" @@ -154,3 +153,12 @@ assert blob "DIDL\02\6a\00\01\01\00\6d\01\01\00\01\01\00\01m" == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (vec Vec)) "(µ vec) <: vec {µ vec}"; assert blob "DIDL\03\6a\00\01\01\00\6d\02\6d\02\01\00\01\01\00\01m" == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (Vec)) "vec {µ vec} <: (µ vec)"; + +// future types +// This uses 0x67 for the “future type”; bump (well, decrement) once that +// becomes a concrete future type + +assert blob "DIDL\02\6a\00\01\01\00\67\00\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (opt empty)) "(future type) <: (opt empty)"; +assert blob "DIDL\02\6a\00\01\01\00\67\00\01\00\01\01\00\01m" + == "(null)" : (opt func () -> (nat)) "(future type) <: (nat)"; From 9420864c1d17076872c36f74e2d9193a89f1e167 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Mon, 5 Dec 2022 08:19:26 +0100 Subject: [PATCH 7/9] Update test/construct.test.did Co-authored-by: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> --- test/construct.test.did | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/construct.test.did b/test/construct.test.did index 0d3ac030f..6e9fe39d8 100644 --- a/test/construct.test.did +++ b/test/construct.test.did @@ -142,7 +142,7 @@ assert blob "DIDL\01\6b\01\00\7f\01\00\00\2a" ! assert blob "DIDL\01\6b\02\00\7f\01\7c\01\00\01\2a" : (variant {0:int; 1:int}) "variant: type mismatch in unused tag"; assert blob "DIDL\01\6b\01\00\7f\01\00\00" == "(variant {0})" : (variant {0;1}) "variant: ignore field"; assert blob "DIDL\01\6b\02\00\7f\01\7f\01\00\00" : (variant {0}) "variant {0;1} <: variant {0}"; -assert blob "DIDL\01\6b\02\00\7f\01\7f\01\00\00" == "(variant {0})" : (opt variant {0}) "variant {0;1} <: opt variant {0}"; +assert blob "DIDL\01\6b\02\00\7f\01\7f\01\00\00" == "(opt variant {0})" : (opt variant {0}) "variant {0;1} <: opt variant {0}"; assert blob "DIDL\01\6b\02\00\7f\01\7f\01\00\01" == "(variant {1})" : (variant {0;1;2}) "variant: change index"; assert blob "DIDL\01\6b\01\00\7f\01\00\00" !: (variant {1}) "variant: missing field"; assert blob "DIDL\01\6b\01\00\7f\01\00\01" !: (variant {0}) "variant: index out of range"; From 98ea8eddee056bd310eb821f7edf7bbe5053aa90 Mon Sep 17 00:00:00 2001 From: Joachim Breitner Date: Mon, 5 Dec 2022 08:19:34 +0100 Subject: [PATCH 8/9] Update test/subtypes.test.did Co-authored-by: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> --- test/subtypes.test.did | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/subtypes.test.did b/test/subtypes.test.did index acc97adeb..4107a9059 100644 --- a/test/subtypes.test.did +++ b/test/subtypes.test.did @@ -161,4 +161,4 @@ assert blob "DIDL\03\6a\00\01\01\00\6d\02\6d\02\01\00\01\01\00\01m" assert blob "DIDL\02\6a\00\01\01\00\67\00\01\00\01\01\00\01m" == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (opt empty)) "(future type) <: (opt empty)"; assert blob "DIDL\02\6a\00\01\01\00\67\00\01\00\01\01\00\01m" - == "(null)" : (opt func () -> (nat)) "(future type) <: (nat)"; + == "(null)" : (opt func () -> (nat)) "(future type) Date: Mon, 5 Dec 2022 08:23:34 +0100 Subject: [PATCH 9/9] =?UTF-8?q?add=20"(=C2=B5=20record)=20<:=20(=CE=BC=20(?= =?UTF-8?q?record=20opt))"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/subtypes.test.did | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/subtypes.test.did b/test/subtypes.test.did index 4107a9059..9db696602 100644 --- a/test/subtypes.test.did +++ b/test/subtypes.test.did @@ -29,6 +29,7 @@ where XX is a type entry table for a non-primitive type t1 type Vec = vec Vec; type EmptyRecord = record { 0 : EmptyRecord }; +type MuRecordOpt = record { 0 : opt MuRecordOpt }; type EmptyVariant = variant { 0: EmptyVariant }; // some reflexive cases @@ -131,6 +132,8 @@ assert blob "DIDL\02\6a\00\01\01\00\6c\01\00\01\01\00\01\01\00\01m" == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (record {EmptyRecord})) "(µ record) <: record {µ record}"; assert blob "DIDL\03\6a\00\01\01\00\6c\01\00\02\6c\01\00\02\01\00\01\01\00\01m" == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (EmptyRecord)) "record {µ record} <: (µ record)"; +assert blob "DIDL\02\6a\00\01\01\00\6c\01\00\01\01\00\01\01\00\01m" + == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (MuRecordOpt)) "(µ record) <: (μ (record opt))"; assert blob "DIDL\02\6a\00\01\01\00\6b\01\00\01\01\00\01\01\00\01m" == "(opt func \"aaaaa-aa\".m)" : (opt func () -> (EmptyVariant)) "(µ variant) <: (µ variant)";