@@ -6,7 +6,7 @@ plan 142;
6
6
7
7
= begin pod
8
8
9
- Misc. Junction tests
9
+ Misc. Junction tests
10
10
11
11
= end pod
12
12
@@ -28,53 +28,53 @@ sub jok(Mu $condition, $msg?) { ok ?($condition), $msg };
28
28
my $ a = ' ' ;
29
29
my $ b = ' ' ;
30
30
my $ c = ' ' ;
31
-
31
+
32
32
# make sure they all match to an empty string
33
33
jok(' ' eq ($ a & $ b & $ c ), ' junction of ($a & $b & $c) matches an empty string' );
34
- jok(' ' eq all ($ a , $ b , $ c ), ' junction of all($a, $b, $c) matches an empty string' );
35
-
34
+ jok(' ' eq all ($ a , $ b , $ c ), ' junction of all($a, $b, $c) matches an empty string' );
35
+
36
36
# give $a a value
37
- $ a = ' a' ;
38
-
39
- # make sure that at least one of them matches 'a'
37
+ $ a = ' a' ;
38
+
39
+ # make sure that at least one of them matches 'a'
40
40
jok(' a' eq ($ b | $ c | $ a ), ' junction of ($b | $c | $a) matches at least one "a"' );
41
- jok(' a' eq any ($ b , $ c , $ a ), ' junction of any($b, $c, $a) matches at least one "a"' );
41
+ jok(' a' eq any ($ b , $ c , $ a ), ' junction of any($b, $c, $a) matches at least one "a"' );
42
42
43
43
jok(' ' eq ($ b | $ c | $ a ), ' junction of ($b | $c | $a) matches at least one empty string' );
44
44
jok(' ' eq any ($ b , $ c , $ a ), ' junction of any($b, $c, $a) matches at least one empty string' );
45
-
45
+
46
46
# make sure that ~only~ one of them matches 'a'
47
47
jok(' a' eq ($ b ^ $ c ^ $ a ), ' junction of ($b ^ $c ^ $a) matches at ~only~ one "a"' );
48
48
jok(' a' eq one ($ b , $ c , $ a ), ' junction of one($b, $c, $a) matches at ~only~ one "a"' );
49
-
49
+
50
50
# give $b a value
51
51
$ b = ' a' ;
52
-
52
+
53
53
# now this will fail
54
- jok(' a' ne ($ b ^ $ c ^ $ a ), ' junction of ($b ^ $c ^ $a) matches at more than one "a"' );
54
+ jok(' a' ne ($ b ^ $ c ^ $ a ), ' junction of ($b ^ $c ^ $a) matches at more than one "a"' );
55
55
56
56
# change $b and give $c a value
57
57
$ b = ' b' ;
58
58
$ c = ' c' ;
59
-
59
+
60
60
jok(' a' eq ($ b ^ $ c ^ $ a ), ' junction of ($b ^ $c ^ $a) matches at ~only~ one "a"' );
61
61
jok(' b' eq ($ a ^ $ b ^ $ c ), ' junction of ($a ^ $b ^ $c) matches at ~only~ one "b"' );
62
- jok(' c' eq ($ c ^ $ a ^ $ b ), ' junction of ($c ^ $a ^ $b) matches at ~only~ one "c"' );
62
+ jok(' c' eq ($ c ^ $ a ^ $ b ), ' junction of ($c ^ $a ^ $b) matches at ~only~ one "c"' );
63
63
64
64
jok(' a' eq ($ b | $ c | $ a ), ' junction of ($b | $c | $a) matches at least one "a"' );
65
65
jok(' b' eq ($ a | $ b | $ c ), ' junction of ($a | $b | $c) matches at least one "b"' );
66
- jok(' c' eq ($ c | $ a | $ b ), ' junction of ($c | $a | $b) matches at least one "c"' );
66
+ jok(' c' eq ($ c | $ a | $ b ), ' junction of ($c | $a | $b) matches at least one "c"' );
67
+
67
68
68
-
69
69
# test junction to junction
70
- jok((' a' | ' b' | ' c' ) eq ($ a & $ b & $ c ), ' junction ("a" | "b" | "c") matches junction ($a & $b & $c)' );
71
- jok((' a' & ' b' & ' c' ) eq ($ a | $ b | $ c ), ' junction ("a" & "b" & "c") matches junction ($a | $b | $c)' );
72
-
70
+ jok((' a' | ' b' | ' c' ) eq ($ a & $ b & $ c ), ' junction ("a" | "b" | "c") matches junction ($a & $b & $c)' );
71
+ jok((' a' & ' b' & ' c' ) eq ($ a | $ b | $ c ), ' junction ("a" & "b" & "c") matches junction ($a | $b | $c)' );
72
+
73
73
# mix around variables and literals
74
-
75
- jok(($ a & ' b' & ' c' ) eq (' a' | $ b | $ c ), ' junction ($a & "b" & "c") matches junction ("a" | $b | $c)' );
76
- jok(($ a & ' b' & $ c ) eq (' a' | $ b | ' c' ), ' junction ($a & "b" & $c) matches junction ("a" | $b | "c")' );
77
-
74
+
75
+ jok(($ a & ' b' & ' c' ) eq (' a' | $ b | $ c ), ' junction ($a & "b" & "c") matches junction ("a" | $b | $c)' );
76
+ jok(($ a & ' b' & $ c ) eq (' a' | $ b | ' c' ), ' junction ($a & "b" & $c) matches junction ("a" | $b | "c")' );
77
+
78
78
}
79
79
80
80
# same tests, but with junctions as variables
@@ -83,41 +83,41 @@ sub jok(Mu $condition, $msg?) { ok ?($condition), $msg };
83
83
my $ a = ' ' ;
84
84
my $ b = ' ' ;
85
85
my $ c = ' ' ;
86
-
86
+
87
87
my Mu $ all_of_them = $ a & $ b & $ c ;
88
88
jok(' ' eq $ all_of_them , ' junction variable of ($a & $b & $c) matches and empty string' );
89
-
90
- $ a = ' a' ;
91
-
89
+
90
+ $ a = ' a' ;
91
+
92
92
my Mu $ any_of_them = $ b | $ c | $ a ;
93
- jok(' a' eq $ any_of_them , ' junction variable of ($b | $c | $a) matches at least one "a"' );
93
+ jok(' a' eq $ any_of_them , ' junction variable of ($b | $c | $a) matches at least one "a"' );
94
94
jok(' ' eq $ any_of_them , ' junction variable of ($b | $c | $a) matches at least one empty string' );
95
-
95
+
96
96
my Mu $ one_of_them = $ b ^ $ c ^ $ a ;
97
97
jok(' a' eq $ one_of_them , ' junction variable of ($b ^ $c ^ $a) matches at ~only~ one "a"' );
98
-
98
+
99
99
$ b = ' a' ;
100
-
100
+
101
101
{
102
102
my Mu $ one_of_them = $ b ^ $ c ^ $ a ;
103
- jok(' a' ne $ one_of_them , ' junction variable of ($b ^ $c ^ $a) matches at more than one "a"' );
103
+ jok(' a' ne $ one_of_them , ' junction variable of ($b ^ $c ^ $a) matches at more than one "a"' );
104
104
}
105
-
105
+
106
106
$ b = ' b' ;
107
107
$ c = ' c' ;
108
-
108
+
109
109
{
110
- my Mu $ one_of_them = $ b ^ $ c ^ $ a ;
110
+ my Mu $ one_of_them = $ b ^ $ c ^ $ a ;
111
111
jok(' a' eq $ one_of_them , ' junction of ($b ^ $c ^ $a) matches at ~only~ one "a"' );
112
112
jok(' b' eq $ one_of_them , ' junction of ($a ^ $b ^ $c) matches at ~only~ one "b"' );
113
- jok(' c' eq $ one_of_them , ' junction of ($c ^ $a ^ $b) matches at ~only~ one "c"' );
113
+ jok(' c' eq $ one_of_them , ' junction of ($c ^ $a ^ $b) matches at ~only~ one "c"' );
114
114
}
115
115
116
116
{
117
117
my Mu $ any_of_them = $ b | $ c | $ a ;
118
118
jok(' a' eq $ any_of_them , ' junction of ($b | $c | $a) matches at least one "a"' );
119
119
jok(' b' eq $ any_of_them , ' junction of ($a | $b | $c) matches at least one "b"' );
120
- jok(' c' eq $ any_of_them , ' junction of ($c | $a | $b) matches at least one "c"' );
120
+ jok(' c' eq $ any_of_them , ' junction of ($c | $a | $b) matches at least one "c"' );
121
121
}
122
122
123
123
}
@@ -142,7 +142,7 @@ sub jok(Mu $condition, $msg?) { ok ?($condition), $msg };
142
142
143
143
= begin description
144
144
145
- Tests junction examples from Synopsis 03
145
+ Tests junction examples from Synopsis 03
146
146
147
147
j() is used to convert a junction to canonical string form, currently
148
148
just using .perl until a better approach presents itself.
@@ -207,7 +207,7 @@ sub j (Mu $j) { return $j.perl }
207
207
208
208
# L<S03/Junctive operators/Junctions are specifically unordered>
209
209
# Compiler *can* reorder and parallelize but *may not* so don't test
210
- # for all(@foo) {...};
210
+ # for all(@foo) {...};
211
211
212
212
# Not sure what is expected
213
213
# my %got = ('1' => 1); # Hashes are unordered too
@@ -224,8 +224,8 @@ These are implemented but still awaiting clarification on p6l.
224
224
On Fri, 2005-02-11 at 10:46 +1100, Damian Conway wrote:
225
225
> Subject: Re: Fwd: Junctive puzzles.
226
226
>
227
- > Junctions have an associated boolean predicate that's preserved across
228
- > operations on the junction. Junctions also implicitly distribute across
227
+ > Junctions have an associated boolean predicate that's preserved across
228
+ > operations on the junction. Junctions also implicitly distribute across
229
229
> operations, and rejunctify the results.
230
230
231
231
= end description
@@ -267,7 +267,7 @@ These are implemented but still awaiting clarification on p6l.
267
267
is (j((1 | 2)^ (3 &4)), j(one (any (1 ,2 ),all (3 ,4 ))),
268
268
' ((1|2)^(3&4)) equiv to one(any(1,2),all(3,4))' );
269
269
270
- is (j((1 | 2)&(3 &4)), j(all (any (1 ,2 ),all (3 ,4 ))),
270
+ is (j((1 | 2)&(3 &4)), j(all (any (1 ,2 ),all (3 ,4 ))),
271
271
' ((1|2)&(3&4)) equiv to all(any(1,2),all(3,4))' );
272
272
273
273
is (j((1 | 2)| (3 &4)), j(any (any (1 ,2 ),all (3 ,4 ))),
@@ -332,15 +332,15 @@ ok Mu & Mu ~~ Mu, 'Mu & Mu ~~ Mu works';
332
332
{
333
333
my Mu $ res = substr (" abcd" , 1 | 2, 2 );
334
334
isa-ok $ res , Junction ;
335
- ok $ res eq " bc" , " substr on junctions: bc" ;
335
+ ok $ res eq " bc" , " substr on junctions: bc" ;
336
336
ok $ res eq " cd" , " substr on junctions: cd" ;
337
337
}
338
338
339
339
{
340
340
my Mu $ res = substr (" abcd" , 1 , 1 | 2);
341
341
isa-ok $ res , Junction ;
342
- ok $ res eq " bc" , " substr on junctions: bc" ;
343
- ok $ res eq " b" , " substr on junctions: b" ;
342
+ ok $ res eq " bc" , " substr on junctions: bc" ;
343
+ ok $ res eq " b" , " substr on junctions: b" ;
344
344
}
345
345
346
346
{
0 commit comments