github.com/solo-io/cue@v0.4.7/cue/testdata/basicrewrite/001_regexp.txtar (about)

     1  # DO NOT EDIT; generated by go run testdata/gen.go
     2  #
     3  #name: regexp
     4  #evalPartial
     5  -- in.cue --
     6  c1: "a" =~ "a"
     7  c2: "foo" =~ "[a-z]{3}"
     8  c3: "foo" =~ "[a-z]{4}"
     9  c4: "foo" !~ "[a-z]{4}"
    10  
    11  b1: =~"a"
    12  b1: "a"
    13  b2: =~"[a-z]{3}"
    14  b2: "foo"
    15  b3: =~"[a-z]{4}"
    16  b3: "foo"
    17  b4: !~"[a-z]{4}"
    18  b4: "foo"
    19  
    20  s1: !="b" & =~"c"     // =~"c"
    21  s2: =~"c" & !="b"     // =~"c"
    22  s3: !="b" & =~"[a-z]" // != "b" & =~"[a-z]"
    23  s4: =~"[a-z]" & !="b" // != "b" & =~"[a-z]"
    24  
    25  e1: "foo" =~ 1
    26  e2: "foo" !~ true
    27  e3: !="a" & <5
    28  -- out/def --
    29  c1: true
    30  c2: true
    31  c3: false
    32  c4: true
    33  b1: "a"
    34  b2: "foo"
    35  b3: _|_ // invalid value "foo" (does not match =~"[a-z]{4}")
    36  b4: "foo"
    37  s1: =~"c"
    38  s2: !="b" & =~"[a-z]"
    39  e1: _|_ // invalid operation "foo" =~ 1 (mismatched types string and int)
    40  e2: _|_ // invalid operation "foo" !~ true (mismatched types string and bool)
    41  e3: _|_ // conflicting values !="a" and <5 (mismatched types string and number)
    42  -- out/legacy-debug --
    43  <0>{c1: true, c2: true, c3: false, c4: true, b1: "a", b2: "foo", b3: _|_((=~"[a-z]{4}" & "foo"):invalid value "foo" (does not match =~"[a-z]{4}")), b4: "foo", s1: =~"c", s2: (!="b" & =~"[a-z]"), e1: _|_(("foo" =~ 1):invalid operation "foo" =~ 1 (mismatched types string and int)), e2: _|_(("foo" !~ true):invalid operation "foo" !~ true (mismatched types string and bool)), e3: _|_((!="a" & <5):conflicting values !="a" and <5 (mismatched types string and number))}
    44  -- out/compile --
    45  --- in.cue
    46  {
    47    c1: ("a" =~ "a")
    48    c2: ("foo" =~ "[a-z]{3}")
    49    c3: ("foo" =~ "[a-z]{4}")
    50    c4: ("foo" !~ "[a-z]{4}")
    51    b1: =~"a"
    52    b1: "a"
    53    b2: =~"[a-z]{3}"
    54    b2: "foo"
    55    b3: =~"[a-z]{4}"
    56    b3: "foo"
    57    b4: !~"[a-z]{4}"
    58    b4: "foo"
    59    s1: (!="b" & =~"c")
    60    s2: (=~"c" & !="b")
    61    s3: (!="b" & =~"[a-z]")
    62    s4: (=~"[a-z]" & !="b")
    63    e1: ("foo" =~ 1)
    64    e2: ("foo" !~ true)
    65    e3: (!="a" & <5)
    66  }
    67  -- out/eval --
    68  Errors:
    69  e3: conflicting values !="a" and <5 (mismatched types string and number):
    70      ./in.cue:22:5
    71      ./in.cue:22:13
    72  b3: invalid value "foo" (out of bound =~"[a-z]{4}"):
    73      ./in.cue:10:5
    74      ./in.cue:11:5
    75  e1: cannot use 1 (type int) as type (string|bytes):
    76      ./in.cue:20:5
    77      ./in.cue:20:14
    78  e2: cannot use true (type bool) as type (string|bytes):
    79      ./in.cue:21:5
    80      ./in.cue:21:14
    81  
    82  Result:
    83  (_|_){
    84    // [eval]
    85    c1: (bool){ true }
    86    c2: (bool){ true }
    87    c3: (bool){ false }
    88    c4: (bool){ true }
    89    b1: (string){ "a" }
    90    b2: (string){ "foo" }
    91    b3: (_|_){
    92      // [eval] b3: invalid value "foo" (out of bound =~"[a-z]{4}"):
    93      //     ./in.cue:10:5
    94      //     ./in.cue:11:5
    95    }
    96    b4: (string){ "foo" }
    97    s1: (string){ =~"c" }
    98    s2: (string){ =~"c" }
    99    s3: (string){ &(!="b", =~"[a-z]") }
   100    s4: (string){ &(=~"[a-z]", !="b") }
   101    e1: (_|_){
   102      // [eval] e1: cannot use 1 (type int) as type (string|bytes):
   103      //     ./in.cue:20:5
   104      //     ./in.cue:20:14
   105    }
   106    e2: (_|_){
   107      // [eval] e2: cannot use true (type bool) as type (string|bytes):
   108      //     ./in.cue:21:5
   109      //     ./in.cue:21:14
   110    }
   111    e3: (_|_){
   112      // [eval] e3: conflicting values !="a" and <5 (mismatched types string and number):
   113      //     ./in.cue:22:5
   114      //     ./in.cue:22:13
   115    }
   116  }