File: 001_regexp.txtar

package info (click to toggle)
golang-github-cue-lang-cue 0.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 19,644 kB
  • sloc: makefile: 20; sh: 15
file content (124 lines) | stat: -rw-r--r-- 3,128 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#name: regexp
#evalPartial
-- in.cue --
c1: "a" =~ "a"
c2: "foo" =~ "[a-z]{3}"
c3: "foo" =~ "[a-z]{4}"
c4: "foo" !~ "[a-z]{4}"

b1: =~"a"
b1: "a"
b2: =~"[a-z]{3}"
b2: "foo"
b3: =~"[a-z]{4}"
b3: "foo"
b4: !~"[a-z]{4}"
b4: "foo"

s1: !="b" & =~"c"     // =~"c"
s2: =~"c" & !="b"     // =~"c"
s3: !="b" & =~"[a-z]" // != "b" & =~"[a-z]"
s4: =~"[a-z]" & !="b" // != "b" & =~"[a-z]"

e1: "foo" =~ 1
e2: "foo" !~ true
e3: !="a" & <5
-- out/def --
c1: true
c2: true
c3: false
c4: true
b1: "a"
b2: "foo"
b3: _|_ // invalid value "foo" (does not match =~"[a-z]{4}")
b4: "foo"
s1: =~"c"
s2: !="b" & =~"[a-z]"
e1: _|_ // invalid operation "foo" =~ 1 (mismatched types string and int)
e2: _|_ // invalid operation "foo" !~ true (mismatched types string and bool)
e3: _|_ // conflicting values !="a" and <5 (mismatched types string and number)
-- out/legacy-debug --
<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))}
-- out/compile --
--- in.cue
{
  c1: ("a" =~ "a")
  c2: ("foo" =~ "[a-z]{3}")
  c3: ("foo" =~ "[a-z]{4}")
  c4: ("foo" !~ "[a-z]{4}")
  b1: =~"a"
  b1: "a"
  b2: =~"[a-z]{3}"
  b2: "foo"
  b3: =~"[a-z]{4}"
  b3: "foo"
  b4: !~"[a-z]{4}"
  b4: "foo"
  s1: (!="b" & =~"c")
  s2: (=~"c" & !="b")
  s3: (!="b" & =~"[a-z]")
  s4: (=~"[a-z]" & !="b")
  e1: ("foo" =~ 1)
  e2: ("foo" !~ true)
  e3: (!="a" & <5)
}
-- out/eval/stats --
Leaks:  0
Freed:  16
Reused: 14
Allocs: 2
Retain: 0

Unifications: 16
Conjuncts:    25
Disjuncts:    16
-- out/eval --
Errors:
e3: conflicting values !="a" and <5 (mismatched types string and number):
    ./in.cue:22:5
    ./in.cue:22:13
b3: invalid value "foo" (out of bound =~"[a-z]{4}"):
    ./in.cue:10:5
    ./in.cue:11:5
e1: cannot use 1 (type int) as type (string|bytes):
    ./in.cue:20:5
    ./in.cue:20:14
e2: cannot use true (type bool) as type (string|bytes):
    ./in.cue:21:5
    ./in.cue:21:14

Result:
(_|_){
  // [eval]
  c1: (bool){ true }
  c2: (bool){ true }
  c3: (bool){ false }
  c4: (bool){ true }
  b1: (string){ "a" }
  b2: (string){ "foo" }
  b3: (_|_){
    // [eval] b3: invalid value "foo" (out of bound =~"[a-z]{4}"):
    //     ./in.cue:10:5
    //     ./in.cue:11:5
  }
  b4: (string){ "foo" }
  s1: (string){ =~"c" }
  s2: (string){ =~"c" }
  s3: (string){ &(!="b", =~"[a-z]") }
  s4: (string){ &(=~"[a-z]", !="b") }
  e1: (_|_){
    // [eval] e1: cannot use 1 (type int) as type (string|bytes):
    //     ./in.cue:20:5
    //     ./in.cue:20:14
  }
  e2: (_|_){
    // [eval] e2: cannot use true (type bool) as type (string|bytes):
    //     ./in.cue:21:5
    //     ./in.cue:21:14
  }
  e3: (_|_){
    // [eval] e3: conflicting values !="a" and <5 (mismatched types string and number):
    //     ./in.cue:22:5
    //     ./in.cue:22:13
  }
}