Marcel van Lohuizen | db18b37 | 2020-09-16 18:25:35 +0200 | [diff] [blame] | 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 | &Conjunction{}, |
| 36 | &Disjunction{}, |
| 37 | &DisjunctionExpr{}, |
| 38 | &DynamicField{}, |
| 39 | &DynamicReference{}, |
| 40 | &Ellipsis{}, |
| 41 | &Field{}, |
| 42 | &FieldReference{}, |
| 43 | &ForClause{}, |
| 44 | &IfClause{}, |
| 45 | &ImportReference{}, |
| 46 | &IndexExpr{}, |
| 47 | &Interpolation{}, |
| 48 | &LabelReference{}, |
| 49 | &LetClause{}, |
| 50 | &LetReference{}, |
| 51 | &ListLit{}, |
| 52 | &ListMarker{}, |
| 53 | &NodeLink{}, |
| 54 | &Null{}, |
| 55 | &Num{}, |
| 56 | &OptionalField{}, |
| 57 | &SelectorExpr{}, |
| 58 | &SliceExpr{}, |
| 59 | &String{}, |
| 60 | &StructLit{}, |
| 61 | &StructMarker{}, |
| 62 | &Top{}, |
| 63 | &UnaryExpr{}, |
| 64 | &ValueClause{}, |
| 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 | } |