diff --git a/cue/interpreter/wasm/testdata/cue/default.txtar b/cue/interpreter/wasm/testdata/cue/default.txtar new file mode 100644 index 000000000..14e24a8fd --- /dev/null +++ b/cue/interpreter/wasm/testdata/cue/default.txtar @@ -0,0 +1,16 @@ +# Check that default values are resolved correctly. + +exec cue eval -E --out cue +cmp stdout out/wasm + +-- a.cue -- +@extern("wasm") +package p + +add: _ @extern("basic.wasm", abi=c, sig="func(int64, int64): int64") + +x0: add(*1 | string, *2 | string) +-- basic.wasm -- +-- out/wasm -- +add: add +x0: 3 \ No newline at end of file diff --git a/cue/testdata/builtins/default.txtar b/cue/testdata/builtins/default.txtar new file mode 100644 index 000000000..0d2c6ca6d --- /dev/null +++ b/cue/testdata/builtins/default.txtar @@ -0,0 +1,59 @@ +-- in.cue -- +import ( + "list" + "strings" + "text/template" +) + +Len: len(*[1, 2, 3] | 0) +Close: close(*{} | 0) +And: and(*[1, 1] | int) +Or: or(*[1, 1] | int) +Div: div(*5 | string, 2) +Mod: mod(*5 | string, 2) +Quo: quo(*5 | string, 2) +Rem: rem(*5 | string, 2) +-- out/compile -- +--- in.cue +{ + Len: len((*[ + 1, + 2, + 3, + ]|0)) + Close: close((*{}|0)) + And: and((*[ + 1, + 1, + ]|int)) + Or: or((*[ + 1, + 1, + ]|int)) + Div: div((*5|string), 2) + Mod: mod((*5|string), 2) + Quo: quo((*5|string), 2) + Rem: rem((*5|string), 2) +} +-- out/eval/stats -- +Leaks: 0 +Freed: 45 +Reused: 40 +Allocs: 5 +Retain: 0 + +Unifications: 25 +Conjuncts: 52 +Disjuncts: 45 +-- out/eval -- +(struct){ + Len: (int){ 3 } + Close: (struct){ + } + And: (int){ 1 } + Or: (int){ 1 } + Div: (int){ 2 } + Mod: (int){ 1 } + Quo: (int){ 2 } + Rem: (int){ 1 } +} diff --git a/pkg/net/testdata/toip4.txtar b/pkg/net/testdata/toip4.txtar new file mode 100644 index 000000000..d6af7156a --- /dev/null +++ b/pkg/net/testdata/toip4.txtar @@ -0,0 +1,21 @@ +-- in.cue -- +import "net" + +fail: { + t1: net.ToIP4(1 | 2) + t2: net.ToIP4(string) +} + +ok: { + t1: net.ToIP4(*"4.4.4.4" | "8.8.8.8") +} +-- out/net -- +import "net" + +fail: { + t1: net.ToIP4(1 | 2) + t2: net.ToIP4(string) +} +ok: { + t1: [4, 4, 4, 4] +} diff --git a/pkg/strings/testdata/join.txtar b/pkg/strings/testdata/join.txtar new file mode 100644 index 000000000..72feb5d71 --- /dev/null +++ b/pkg/strings/testdata/join.txtar @@ -0,0 +1,6 @@ +-- in.cue -- +import "strings" + +disjunctDefault: strings.Join(*["Hello", "World!"] | int, " ") +-- out/strings -- +disjunctDefault: "Hello World!"