cuelang.org/go@v0.10.1/internal/core/adt/expr_test.go (about) 1 // Copyright 2020 CUE Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package adt 16 17 import ( 18 "fmt" 19 "testing" 20 ) 21 22 func TestNilSource(t *testing.T) { 23 testCases := []Node{ 24 &BasicType{}, 25 &BinaryExpr{}, 26 &Bool{}, 27 &Bottom{}, 28 &BoundExpr{}, 29 &BoundValue{}, 30 &Builtin{}, 31 &BuiltinValidator{}, 32 &BulkOptionalField{}, 33 &Bytes{}, 34 &CallExpr{}, 35 &Comprehension{}, 36 &Conjunction{}, 37 &Disjunction{}, 38 &DisjunctionExpr{}, 39 &DynamicField{}, 40 &DynamicReference{}, 41 &Ellipsis{}, 42 &Field{}, 43 &FieldReference{}, 44 &ForClause{}, 45 &IfClause{}, 46 &ImportReference{}, 47 &IndexExpr{}, 48 &Interpolation{}, 49 &LabelReference{}, 50 &LetClause{}, 51 &LetField{}, 52 &LetReference{}, 53 &ListLit{}, 54 &ListMarker{}, 55 &NodeLink{}, 56 &Null{}, 57 &Num{}, 58 &SelectorExpr{}, 59 &SliceExpr{}, 60 &String{}, 61 &StructLit{}, 62 &StructMarker{}, 63 &Top{}, 64 &UnaryExpr{}, 65 &Vertex{}, 66 } 67 for _, x := range testCases { 68 t.Run(fmt.Sprintf("%T", x), func(t *testing.T) { 69 if x.Source() != nil { 70 t.Error("nil source did not return nil") 71 } 72 }) 73 } 74 }