1// Copyright (c) 2021, Peter Ohler, All rights reserved. 2 3package asm_test 4 5import ( 6 "testing" 7 8 "github.com/ohler55/ojg/asm" 9 "github.com/ohler55/ojg/sen" 10 "github.com/ohler55/ojg/tt" 11) 12 13func TestRoot(t *testing.T) { 14 root := testPlan(t, 15 `[ 16 [set $.asm [get [root src x]]] 17 ]`, 18 "{src: {x:3}}", 19 ) 20 tt.Equal(t, `3`, sen.String(root["asm"], &sopt)) 21} 22 23func TestRootArgNotString(t *testing.T) { 24 p := asm.NewPlan([]interface{}{ 25 []interface{}{"root", 1}, 26 }) 27 err := p.Execute(map[string]interface{}{}) 28 tt.NotNil(t, err) 29} 30 31func TestRootArgParseError(t *testing.T) { 32 p := asm.NewPlan([]interface{}{ 33 []interface{}{"root", "[[["}, 34 }) 35 err := p.Execute(map[string]interface{}{}) 36 tt.NotNil(t, err) 37} 38