| 1 | package execution_test |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/tomwright/dasel/v3/model" |
| 7 | ) |
| 8 | |
| 9 | func TestFuncTypeOf(t *testing.T) { |
| 10 | t.Run("string", testCase{ |
| 11 | s: `typeOf("hello")`, |
| 12 | out: model.NewStringValue("string"), |
| 13 | }.run) |
| 14 | t.Run("int", testCase{ |
| 15 | s: `typeOf(123)`, |
| 16 | out: model.NewStringValue("int"), |
| 17 | }.run) |
| 18 | t.Run("float", testCase{ |
| 19 | s: `typeOf(12.3)`, |
| 20 | out: model.NewStringValue("float"), |
| 21 | }.run) |
| 22 | t.Run("bool", testCase{ |
| 23 | s: `typeOf(true)`, |
| 24 | out: model.NewStringValue("bool"), |
| 25 | }.run) |
| 26 | t.Run("array", testCase{ |
| 27 | s: `typeOf([])`, |
| 28 | out: model.NewStringValue("array"), |
| 29 | }.run) |
| 30 | t.Run("map", testCase{ |
| 31 | s: `typeOf({})`, |
| 32 | out: model.NewStringValue("map"), |
| 33 | }.run) |
| 34 | t.Run("null", testCase{ |
| 35 | s: `typeOf(null)`, |
| 36 | out: model.NewStringValue("null"), |
| 37 | }.run) |
| 38 | } |