...

Text file src/cuelang.org/go/pkg/regexp/testdata/gen.txtar

Documentation: cuelang.org/go/pkg/regexp/testdata

     1# generated from the original tests.
     2# Henceforth it may be nicer to group tests into separate files.
     3-- in.cue --
     4import "regexp"
     5
     6t1:  regexp.Find(#"f\w\w"#, "afoot")
     7t2:  regexp.Find(#"f\w\w"#, "bar")
     8t3:  regexp.FindAll(#"f\w\w"#, "afoot afloat from", 2)
     9t4:  regexp.FindAll(#"f\w\w"#, "bla bla", -1)
    10t5:  regexp.FindSubmatch(#"f(\w)(\w)"#, "afloat afoot from")
    11t6:  regexp.FindAllSubmatch(#"f(\w)(\w)"#, "afloat afoot from", -1)
    12t7:  regexp.FindAllSubmatch(#"f(\w)(\w)"#, "aglom", -1)
    13t8:  regexp.FindNamedSubmatch(#"f(?P<A>\w)(?P<B>\w)"#, "afloat afoot from")
    14t9:  regexp.FindAllNamedSubmatch(#"f(?P<A>\w)(?P<B>\w)"#, "afloat afoot from", -1)
    15t10: regexp.FindAllNamedSubmatch(#"f(?P<A>optional)?"#, "fbla", -1)
    16t11: regexp.FindAllNamedSubmatch(#"f(?P<A>\w)(?P<B>\w)"#, "aglom", -1)
    17t12: regexp.Valid & "valid"
    18t13: regexp.Valid & "invalid)"
    19
    20// The following two calls should be identical
    21t14: regexp.ReplaceAll(#"f(?P<A>\w)(?P<B>\w)"#, "afloat afoot from", "-${A}-${B}-")
    22t14: regexp.ReplaceAll(#"f(?P<A>\w)(?P<B>\w)"#, "afloat afoot from", "-$1-$2-")
    23
    24t15: regexp.ReplaceAllLiteral(#"f(?P<A>\w)(?P<B>\w)"#, "afloat afoot from", "-${A}-${B}-")
    25t16: regexp.ReplaceAllLiteral(#"f(?P<A>\w)(?P<B>\w)"#, "afloat afoot from", "-$1-$2-")
    26-- out/regexp --
    27Errors:
    28t13: invalid value "invalid)" (does not satisfy regexp.Valid): error in call to regexp.Valid: error parsing regexp: unexpected ): `invalid)`:
    29    ./in.cue:15:6
    30    ./in.cue:15:21
    31t2: error in call to regexp.Find: no match:
    32    ./in.cue:4:6
    33t4: error in call to regexp.FindAll: no match:
    34    ./in.cue:6:6
    35t7: error in call to regexp.FindAllSubmatch: no match:
    36    ./in.cue:9:6
    37t11: error in call to regexp.FindAllNamedSubmatch: no match:
    38    ./in.cue:13:6
    39
    40Result:
    41t1: "foo"
    42t2: _|_ // t2: error in call to regexp.Find: no match
    43t3: ["foo", "flo"]
    44t4: _|_ // t4: error in call to regexp.FindAll: no match
    45t5: ["flo", "l", "o"]
    46t6: [["flo", "l", "o"], ["foo", "o", "o"], ["fro", "r", "o"]]
    47t7: _|_ // t7: error in call to regexp.FindAllSubmatch: no match
    48t8: {
    49	A: "l"
    50	B: "o"
    51}
    52t9: [{
    53	A: "l"
    54	B: "o"
    55}, {
    56	A: "o"
    57	B: "o"
    58}, {
    59	A: "r"
    60	B: "o"
    61}]
    62t10: [{
    63	A: ""
    64}]
    65t11: _|_ // t11: error in call to regexp.FindAllNamedSubmatch: no match
    66t12: "valid"
    67t13: _|_ // t13: invalid value "invalid)" (does not satisfy regexp.Valid): t13: error in call to regexp.Valid: error parsing regexp: unexpected ): `invalid)`
    68
    69// The following two calls should be identical
    70t14: "a-l-o-at a-o-o-t -r-o-m"
    71t15: "a-${A}-${B}-at a-${A}-${B}-t -${A}-${B}-m"
    72t16: "a-$1-$2-at a-$1-$2-t -$1-$2-m"

View as plain text