URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [regexp/] [syntax/] [prog_test.go] - Rev 747
Compare with Previous | Blame | View Log
// Copyright 2011 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package syntax_testimport (. "regexp/syntax""testing")var compileTests = []struct {Regexp stringProg string}{{"a", ` 0 fail1* rune1 "a" -> 22 match`},{"[A-M][n-z]", ` 0 fail1* rune "AM" -> 22 rune "nz" -> 33 match`},{"", ` 0 fail1* nop -> 22 match`},{"a?", ` 0 fail1 rune1 "a" -> 32* alt -> 1, 33 match`},{"a??", ` 0 fail1 rune1 "a" -> 32* alt -> 3, 13 match`},{"a+", ` 0 fail1* rune1 "a" -> 22 alt -> 1, 33 match`},{"a+?", ` 0 fail1* rune1 "a" -> 22 alt -> 3, 13 match`},{"a*", ` 0 fail1 rune1 "a" -> 22* alt -> 1, 33 match`},{"a*?", ` 0 fail1 rune1 "a" -> 22* alt -> 3, 13 match`},{"a+b+", ` 0 fail1* rune1 "a" -> 22 alt -> 1, 33 rune1 "b" -> 44 alt -> 3, 55 match`},{"(a+)(b+)", ` 0 fail1* cap 2 -> 22 rune1 "a" -> 33 alt -> 2, 44 cap 3 -> 55 cap 4 -> 66 rune1 "b" -> 77 alt -> 6, 88 cap 5 -> 99 match`},{"a+|b+", ` 0 fail1 rune1 "a" -> 22 alt -> 1, 63 rune1 "b" -> 44 alt -> 3, 65* alt -> 1, 36 match`},{"A[Aa]", ` 0 fail1* rune1 "A" -> 22 rune "A"/i -> 33 match`},{"(?:(?:^).)", ` 0 fail1* empty 4 -> 22 anynotnl -> 33 match`},}func TestCompile(t *testing.T) {for _, tt := range compileTests {re, _ := Parse(tt.Regexp, Perl)p, _ := Compile(re)s := p.String()if s != tt.Prog {t.Errorf("compiled %#q:\n--- have\n%s---\n--- want\n%s---", tt.Regexp, s, tt.Prog)}}}
