-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcheckbuiltin_make_test.go
64 lines (50 loc) · 1.91 KB
/
checkbuiltin_make_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package eval
import (
"testing"
)
// TODO the make() type check in gc 1.2 is quite broken. Delete these tests
// and enable the generated make() tests in 1.3
func TestCheckBuiltinMakeMissingArgs(t *testing.T) {
env := MakeSimpleEnv()
expectCheckError(t, "make()", env, "missing argument to make")
}
func TestCheckBuiltinMakeUntypedIntFirstArg(t *testing.T) {
env := MakeSimpleEnv()
expectCheckError(t, "make(1)", env, "1 is not a type")
}
func TestCheckBuiltinMakeTypedIntFirstArg(t *testing.T) {
env := MakeSimpleEnv()
expectCheckError(t, "make(int(1))", env, "int(1) is not a type")
}
func TestCheckBuiltinMakeTypedNilFirstArg(t *testing.T) {
env := MakeSimpleEnv()
expectCheckError(t, "make(nil)", env, "nil is not a type")
}
func TestCheckBuiltinMakeSecondArgNotInt(t *testing.T) {
env := MakeSimpleEnv()
expectCheckError(t, "make([]int, true)", env, "make: non-integer len argument true")
}
func TestCheckBuiltinMakeThirdArgNotInt(t *testing.T) {
env := MakeSimpleEnv()
expectCheckError(t, "make([]int, 1, bool(true))", env, "make: non-integer cap argument bool(true)")
}
func TestCheckBuiltinMakeChanTooManyArgs(t *testing.T) {
env := MakeSimpleEnv()
expectCheckError(t, "make(chan<- int, 1, 1)", env, "too many arguments to make: make(chan<- int, 1, 1)")
}
func TestCheckBuiltinMakeSliceTooFew(t *testing.T) {
env := MakeSimpleEnv()
expectCheckError(t, "make([]int)", env, "too few arguments to make: make([]int)")
}
func TestCheckBuiltinMakeSliceTooManyArgs(t *testing.T) {
env := MakeSimpleEnv()
expectCheckError(t, "make([]int, 1, 1, 1)", env, "too many arguments to make: make([]int, 1, 1, 1)")
}
func TestCheckBuiltinMakeSliceLenGtrThanCap(t *testing.T) {
env := MakeSimpleEnv()
expectCheckError(t, "make([]int, 3, 2)", env, "len larger than cap in make([]int, 3, 2)")
}
func TestCheckBuiltinMakeBadType(t *testing.T) {
env := MakeSimpleEnv()
expectCheckError(t, "make(int)", env, "cannot make type int")
}