{`!@#$%^&*()_+-=[{]}\|,<.>/?~`, `!@#\$%\^&\*\(\)_\+-=\[\{\]\}\\\|,<\.>/\?~`, `!@#`, false},
}
+var literalPrefixTests = []MetaTest{
+ // See golang.org/issue/11175.
+ // output is unused.
+ {`^0^0$`, ``, `0`, false},
+ {`^0^`, ``, ``, false},
+ {`^0$`, ``, `0`, true},
+ {`$0^`, ``, ``, false},
+ {`$0$`, ``, ``, false},
+ {`^^0$$`, ``, ``, false},
+ {`^$^$`, ``, ``, false},
+ {`$$0^^`, ``, ``, false},
+}
+
func TestQuoteMeta(t *testing.T) {
for _, tc := range metaTests {
// Verify that QuoteMeta returns the expected string.
}
func TestLiteralPrefix(t *testing.T) {
- for _, tc := range metaTests {
+ for _, tc := range append(metaTests, literalPrefixTests...) {
// Literal method needs to scan the pattern.
re := MustCompile(tc.pattern)
str, complete := re.LiteralPrefix()
buf.WriteRune(i.Rune[0])
pc, i = i.Out, &p.Inst[i.Out]
}
- return buf.String(), i.Op == syntax.InstEmptyWidth && (syntax.EmptyOp(i.Arg))&syntax.EmptyBeginText != 0, pc
+ if i.Op == syntax.InstEmptyWidth &&
+ syntax.EmptyOp(i.Arg)&syntax.EmptyEndText != 0 &&
+ p.Inst[i.Out].Op == syntax.InstMatch {
+ complete = true
+ }
+ return buf.String(), complete, pc
}
// OnePassNext selects the next actionable state of the prog, based on the input character.