operator-unset.go: fixed function removal
This commit is contained in:
		
							parent
							
								
									032916d4fa
								
							
						
					
					
						commit
						be3bb12f28
					
				| @ -23,7 +23,7 @@ func deleteContextItem(ctx ExprContext, opTerm *term, item any) (deleted bool, e | |||||||
| 		var size int | 		var size int | ||||||
| 		if strings.HasSuffix(name, "()") { | 		if strings.HasSuffix(name, "()") { | ||||||
| 			size = ctx.FuncCount() | 			size = ctx.FuncCount() | ||||||
| 			ctx.DeleteVar(strings.TrimRight(name, "()")) | 			ctx.DeleteFunc(strings.TrimRight(name, "()")) | ||||||
| 			deleted = ctx.FuncCount() < size | 			deleted = ctx.FuncCount() < size | ||||||
| 		} else { | 		} else { | ||||||
| 			size = ctx.VarCount() | 			size = ctx.VarCount() | ||||||
|  | |||||||
| @ -13,10 +13,11 @@ func TestOperator(t *testing.T) { | |||||||
| 	inputs := []inputType{ | 	inputs := []inputType{ | ||||||
| 		/*   1 */ {`a=1; unset "a"; a`, nil, `undefined variable or function "a"`}, | 		/*   1 */ {`a=1; unset "a"; a`, nil, `undefined variable or function "a"`}, | ||||||
| 		/*   2 */ {`a=1; unset ["a", "b"]`, int64(1), nil}, | 		/*   2 */ {`a=1; unset ["a", "b"]`, int64(1), nil}, | ||||||
|  | 		/*   3 */ {`f=func(){3}; unset "f()"`, int64(1), nil}, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// t.Setenv("EXPR_PATH", ".")
 | 	// t.Setenv("EXPR_PATH", ".")
 | ||||||
| 
 | 
 | ||||||
| 	runTestSuiteSpec(t, section, inputs, 2) | 	//runTestSuiteSpec(t, section, inputs, 3)
 | ||||||
| 	//runTestSuite(t, section, inputs)
 | 	runTestSuite(t, section, inputs) | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user