Skip to content

Commit cead43c

Browse files
committed
Fix matches with dyn regexp
1 parent 82b3eb2 commit cead43c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

vm/vm.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ func (vm *VM) Run() interface{} {
209209
case OpMatches:
210210
b := vm.pop()
211211
a := vm.pop()
212-
213-
match, err := regexp.MatchString(a.(string), b.(string))
212+
match, err := regexp.MatchString(b.(string), a.(string))
214213
if err != nil {
215214
panic(err)
216215
}

vm/vm_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ func TestRun(t *testing.T) {
127127
`String matches "s.+"`,
128128
true,
129129
},
130+
{
131+
`String matches ("^" + String + "$")`,
132+
true,
133+
},
134+
{
135+
`"foobar" contains "bar"`,
136+
true,
137+
},
130138
{
131139
`(0..10)[5]`,
132140
int64(5),

0 commit comments

Comments
 (0)