this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cmd/cue: add regression test for ranged numeric type names

Cover both `cue def` output and conflict error messages for
int16, uint8, float32, float64, int64, and uint.

`cue def` already collapses these cases to their predeclared names,
so the stdout expectation is already the desired form.
Error messages with the debug printer do not collapse names yet.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Id431a772360ad6bd447b534f361e772b5df7cda1
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1236170
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>

+70 -19
+38
cmd/cue/cmd/testdata/script/numeric_ranges.txtar
··· 1 + # Predeclared ranged numeric types must render by name rather than as their 2 + # expanded bounds, both in "cue def" output and in error messages. 3 + 4 + exec cue def schema.cue 5 + cmp stdout expect-stdout 6 + 7 + ! exec cue export bad.cue 8 + cmp stderr expect-stderr 9 + 10 + -- schema.cue -- 11 + a: int16 12 + b: uint8 13 + c: float32 14 + d: float64 15 + e: int64 16 + -- expect-stdout -- 17 + a: int16 18 + b: uint8 19 + c: float32 20 + d: float64 21 + e: int64 22 + -- bad.cue -- 23 + i16: int16 & "foo" 24 + u8: uint8 & "foo" 25 + f32: float32 & "foo" 26 + f64: float64 & "foo" 27 + un: uint & "foo" 28 + -- expect-stderr -- 29 + f32: conflicting values >=-340282346638528859811704183484516925440 & <=340282346638528859811704183484516925440 and "foo" (mismatched types number and string): 30 + ./bad.cue:3:16 31 + f64: conflicting values >=-1.797693134862315708145274237317043567981E+308 & <=1.797693134862315708145274237317043567981E+308 and "foo" (mismatched types number and string): 32 + ./bad.cue:4:16 33 + i16: conflicting values int & >=-32768 & <=32767 and "foo" (mismatched types int and string): 34 + ./bad.cue:1:14 35 + u8: conflicting values int & >=0 & <=255 and "foo" (mismatched types int and string): 36 + ./bad.cue:2:14 37 + un: conflicting values int & >=0 and "foo" (mismatched types int and string): 38 + ./bad.cue:5:13
+20 -19
cue/testdata/resolve/046_predefined_ranges.txtar
··· 1 + #inlinetest:exclude skip — tests the debug printer, not evaluator semantics 1 2 -- in.cue -- 2 3 k1: int8 3 - k1: 44 @test(eq, 44) 4 + k1: 44 4 5 5 6 k2: int64 6 - k2: -8_000_000_000 @test(eq, -8000000000) 7 + k2: -8_000_000_000 7 8 8 - e1: int16 9 - e1: 100_000 @test(err, code=eval, contains="invalid value 100000", pos=[0:5]) 10 - -- out/errors.txt -- 11 - [eval] e1: invalid value 100000 (out of bound <=32767): 12 - ./in.cue:8:5 9 + s1: int8 10 + s2: uint16 11 + s3: float32 12 + s4: uint 13 + -- out/evalalpha -- 14 + (struct){ 15 + k1: (int){ 44 } 16 + k2: (int){ -8000000000 } 17 + s1: (int){ &(>=-128, <=127, int) } 18 + s2: (int){ &(>=0, <=65535, int) } 19 + s3: (number){ &(>=-340282346638528859811704183484516925440, <=340282346638528859811704183484516925440) } 20 + s4: (int){ &(>=0, int) } 21 + } 13 22 -- out/compile -- 14 23 --- in.cue 15 24 { ··· 17 26 k1: 44 18 27 k2: &(int, >=-9223372036854775808, <=9223372036854775807) 19 28 k2: -8000000000 20 - e1: &(int, >=-32768, <=32767) 21 - e1: 100000 29 + s1: &(int, >=-128, <=127) 30 + s2: &(int, >=0, <=65535) 31 + s3: &(>=-340282346638528859811704183484516925440, <=340282346638528859811704183484516925440) 32 + s4: &(int, >=0) 22 33 } 23 - -- out/eval/stats -- 24 - Leaks: 0 25 - Freed: 4 26 - Reused: 0 27 - Allocs: 4 28 - Retain: 0 29 - 30 - Unifications: 4 31 - Conjuncts: 7 32 - Disjuncts: 0
+12
cue/testdata/resolve/046_predefined_ranges_error.txtar
··· 1 + -- in.cue -- 2 + e1: int16 3 + e1: 100_000 @test(err, code=eval, contains="invalid value 100000", pos=[0:5]) 4 + -- out/errors.txt -- 5 + [eval] e1: invalid value 100000 (out of bound <=32767): 6 + ./in.cue:2:5 7 + -- out/compile -- 8 + --- in.cue 9 + { 10 + e1: &(int, >=-32768, <=32767) 11 + e1: 100000 12 + }