| 1 | package astscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ |
| 2 | |
| 3 | import "testingscip-go gomod github.com/golang/go/src go1.25 testing/" |
| 4 | |
| 5 | // TestExpr_expr tests the expr method of all the types in the ast package. |
| 6 | // Note that this doesn't actually do anything and is just forcing test coverage. |
| 7 | // The expr func only exists for type safety with the Expr interface. |
| 8 | func TestExpr_exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/TestExpr_expr().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 9 | NumberFloatExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/NumberFloatExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/NumberFloatExpr#expr().() |
| 10 | NumberIntExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/NumberIntExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/NumberIntExpr#expr().() |
| 11 | StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#expr().() |
| 12 | BoolExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/BoolExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/BoolExpr#expr().() |
| 13 | BinaryExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/BinaryExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/BinaryExpr#expr().() |
| 14 | UnaryExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/UnaryExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/UnaryExpr#expr().() |
| 15 | CallExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/CallExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/CallExpr#expr().() |
| 16 | ChainedExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainedExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainedExpr#expr().() |
| 17 | SpreadExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/SpreadExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/SpreadExpr#expr().() |
| 18 | RangeExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/RangeExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/RangeExpr#expr().() |
| 19 | IndexExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/IndexExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/IndexExpr#expr().() |
| 20 | ArrayExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ArrayExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ArrayExpr#expr().() |
| 21 | PropertyExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/PropertyExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/PropertyExpr#expr().() |
| 22 | ObjectExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ObjectExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ObjectExpr#expr().() |
| 23 | MapExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/MapExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/MapExpr#expr().() |
| 24 | EachExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/EachExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/EachExpr#expr().() |
| 25 | VariableExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/VariableExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/VariableExpr#expr().() |
| 26 | GroupExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/GroupExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/GroupExpr#expr().() |
| 27 | ConditionalExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ConditionalExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ConditionalExpr#expr().() |
| 28 | BranchExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/BranchExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/BranchExpr#expr().() |
| 29 | FilterExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/FilterExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/FilterExpr#expr().() |
| 30 | SearchExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/SearchExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/SearchExpr#expr().() |
| 31 | RecursiveDescentExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/RecursiveDescentExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/RecursiveDescentExpr#expr().() |
| 32 | SortByExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/SortByExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/SortByExpr#expr().() |
| 33 | GroupByExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/GroupByExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/GroupByExpr#expr().() |
| 34 | ReduceExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ReduceExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ReduceExpr#expr().() |
| 35 | MapValuesExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/MapValuesExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/MapValuesExpr#expr().() |
| 36 | AnyExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/AnyExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/AnyExpr#expr().() |
| 37 | AllExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/AllExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/AllExpr#expr().() |
| 38 | CountExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/CountExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/CountExpr#expr().() |
| 39 | AssignExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/AssignExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/AssignExpr#expr().() |
| 40 | NullExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/NullExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/NullExpr#expr().() |
| 41 | RegexExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/RegexExpr#{}.exprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/RegexExpr#expr().() |
| 42 | } |
| 43 | |
| 44 | func TestChainExprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/TestChainExprs().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 45 | // 0 args → nil. |
| 46 | if got := ChainExprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainExprs().(); got != nil { |
| 47 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("expected nil, got %v", got) |
| 48 | } |
| 49 | |
| 50 | // 1 arg → returns that arg unwrapped. |
| 51 | single := StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.: "a"} |
| 52 | if got := ChainExprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainExprs().(single); got != single { |
| 53 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("expected single expr returned as-is, got %T", got) |
| 54 | } |
| 55 | |
| 56 | // 2+ args → ChainedExpr. |
| 57 | a := StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.: "a"} |
| 58 | b := StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.: "b"} |
| 59 | result := ChainExprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainExprs().(a, b) |
| 60 | chained, ok := result.(ChainedExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainedExpr#) |
| 61 | if !ok { |
| 62 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("expected ChainedExpr, got %T", result) |
| 63 | } |
| 64 | if len(chained.Exprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainedExpr#Exprs.) != 2 { |
| 65 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("expected 2 exprs, got %d", len(chained.Exprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainedExpr#Exprs.)) |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | func TestBranchExprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/TestBranchExprs().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 70 | a := StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.: "a"} |
| 71 | b := StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.: "b"} |
| 72 | result := BranchExprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/BranchExprs().(a, b) |
| 73 | branch, ok := result.(BranchExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/BranchExpr#) |
| 74 | if !ok { |
| 75 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("expected BranchExpr, got %T", result) |
| 76 | } |
| 77 | if len(branch.Exprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/BranchExpr#Exprs.) != 2 { |
| 78 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("expected 2 exprs, got %d", len(branch.Exprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/BranchExpr#Exprs.)) |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | func TestIsTypescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/TestIsType().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 83 | s := StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.: "x"} |
| 84 | if !IsTypescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/IsType().[StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#](s) { |
| 85 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected IsType[StringExpr] to be true") |
| 86 | } |
| 87 | if IsTypescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/IsType().[NumberIntExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/NumberIntExpr#](s) { |
| 88 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected IsType[NumberIntExpr] to be false") |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | func TestAsTypescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/TestAsType().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 93 | s := StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.: "x"} |
| 94 | got, ok := AsTypescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/AsType().[StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#](s) |
| 95 | if !ok { |
| 96 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected AsType to succeed") |
| 97 | } |
| 98 | if got.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value. != "x" { |
| 99 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("expected x, got %s", got.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.) |
| 100 | } |
| 101 | |
| 102 | _, ok = AsTypescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/AsType().[NumberIntExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/NumberIntExpr#](s) |
| 103 | if ok { |
| 104 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected AsType to fail for wrong type") |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | func TestLastscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/TestLast().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 109 | a := StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.: "a"} |
| 110 | b := StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.: "b"} |
| 111 | c := StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.: "c"} |
| 112 | |
| 113 | // Chained → last element. |
| 114 | chain := ChainedExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainedExpr#{Exprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainedExpr#Exprs.: Expressionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/Expressions#{a, b, c}} |
| 115 | if got := Lastscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/Last().(chain); got != c { |
| 116 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("expected last to be c, got %v", got) |
| 117 | } |
| 118 | |
| 119 | // Non-chained → passthrough. |
| 120 | if got := Lastscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/Last().(a); got != a { |
| 121 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("expected passthrough, got %v", got) |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | func TestLastAsTypescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/TestLastAsType().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 126 | a := NumberIntExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/NumberIntExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/NumberIntExpr#Value.: 1} |
| 127 | b := StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.: "end"} |
| 128 | chain := ChainedExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainedExpr#{Exprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainedExpr#Exprs.: Expressionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/Expressions#{a, b}} |
| 129 | |
| 130 | got, ok := LastAsTypescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/LastAsType().[StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#](chain) |
| 131 | if !ok { |
| 132 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected LastAsType to succeed") |
| 133 | } |
| 134 | if got.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value. != "end" { |
| 135 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("expected end, got %s", got.Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.) |
| 136 | } |
| 137 | |
| 138 | _, ok = LastAsTypescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/LastAsType().[NumberIntExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/NumberIntExpr#](chain) |
| 139 | if ok { |
| 140 | t.Fatalscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatal().("expected LastAsType to fail for wrong type") |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | func TestRemoveLastscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/TestRemoveLast().(t *testingscip-go gomod github.com/golang/go/src go1.25 testing/.Tscip-go gomod github.com/golang/go/src go1.25 testing/T#) { |
| 145 | a := StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.: "a"} |
| 146 | b := StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.: "b"} |
| 147 | c := StringExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#{Valuescip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/StringExpr#Value.: "c"} |
| 148 | |
| 149 | // Chain of 3 → chain of 2. |
| 150 | chain := ChainedExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainedExpr#{Exprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainedExpr#Exprs.: Expressionsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/Expressions#{a, b, c}} |
| 151 | result := RemoveLastscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/RemoveLast().(chain) |
| 152 | chained, ok := result.(ChainedExprscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainedExpr#) |
| 153 | if !ok { |
| 154 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("expected ChainedExpr, got %T", result) |
| 155 | } |
| 156 | if len(chained.Exprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainedExpr#Exprs.) != 2 { |
| 157 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("expected 2 exprs, got %d", len(chained.Exprsscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/ChainedExpr#Exprs.)) |
| 158 | } |
| 159 | |
| 160 | // Single expr → nil (RemoveLast on non-chained yields ChainExprs() with 0 args). |
| 161 | if got := RemoveLastscip-go gomod github.com/tomwright/dasel/v3 . `github.com/tomwright/dasel/v3/selector/ast`/RemoveLast().(a); got != nil { |
| 162 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25 testing/common#Fatalf().("expected nil, got %v", got) |
| 163 | } |
| 164 | } |