cuelang.org/go@v0.10.1/pkg/regexp/testdata/gen.txtar (about)

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