-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg: add some tests that pick defaults in builtins
These tests should not change with an upcoming CL that to support pkg.Schema. Issue #2471 Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com> Change-Id: Ic941ea65432dfdd23743692c1e1efefc8de9da95 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199623 TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Dispatch-Trailer: {"type":"trybot","CL":1199623,"patchset":4,"ref":"refs/changes/23/1199623/4","targetBranch":"master"}
- Loading branch information
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- in.cue -- | ||
import "strings" | ||
|
||
disjunctDefault: strings.Join(*["Hello", "World!"] | int, " ") | ||
-- out/strings -- | ||
disjunctDefault: "Hello World!" |