-
Notifications
You must be signed in to change notification settings - Fork 7
/
future_comparisons.pp
51 lines (38 loc) · 2.03 KB
/
future_comparisons.pp
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
# regex equality? sure.
notice(/t[est]/ == /t[est]/) # true
notice(/t[est]/ == /te[st]/) # false
# types, which I feel like we covered elsewhere but
notice(File == Resource) # false, whew.
notice(File < Resource) # true
notice(File['/tmp/thing'] < File)
notice( "thing" =~ /t[hi]{2}ng/ ) # true
$myregex = /t[hi]{2}ng/
notice( "thing" =~ $myregex ) # true
$mystringregex = "t[hi]{2}ng"
notice( "thing" =~ $mystringregex ) # true
# notice( ["thing", "other"] =~ $myregex ) # error
notice(File <= Resource) # true
notice(1 == Integer) # false and OK
# notice(1 <= Integer) # error!
notice('Eat' in ['eat', 'ate', 'eating']) # true!
notice('Eat' in { 'eat' => 'present tense', 'ate' => 'past tense'} ) # true! That one actually probably isn't what you want...
notice( Integer[100, 199] in [1, 2, 125] ) # true
notice( Integer[100, 199] in 125 ) # false but not error.
notice( String in "hi there" ) # false as well.
notice( /[aeiou]+t/ in { 'eat' => 'present tense', 'ate' => 'past tense'} ) # true
notice( /[aeiou]+tt/ in { 'eat' => 'present tense', 'ate' => 'past tense'} ) # false
# How's array addition work?
notice( [1, 2, 3] + 1 ) # [1, 2, 3, 1]
notice( [1, 2, 3] + [1] ) # [1, 2, 3, 1]
notice( [1, 2, 3] + [[1]] ) # [1, 2, 3, [1]]
# How's array subtraction work?
notice( [1, 2, 3, 4, 5] - 1 ) # [2, 3, 4, 5]
notice( [1, 2, 3, 4, 5, 1, 1] - 1 ) # [2, 3, 4, 5]
notice( [1, 2, 3, 4, 5] - 1 - 1 - 2) # [3, 4, 5]
notice( [1, 2, 3, 4, 5] - [1, 3] ) # [2, 4, 5]
notice( [1, 2, 3, 4, 5] - [[1]] ) # [1, 2, 3, 4, 5]
notice( [ {a => 1}, {b => 2}, 2 ] - {b => 2} ) # [{a => 1}, {b => 2}, 2] -- so huh, only scalar values get the automatic array wrapping.
notice( [ {a => 1}, {b => 2}, 2 ] - [{b => 2}] )# [{a => 1}, 2]
notice( [ {a => 1}, {b => 2}, 2 ] - 2 ) # [{a => 1}, {b => 2}]
notice( [ {a => 1}, {b => 2}, 2 ] + {b => 2} ) # [{a => 1}, {b => 2}, 2, [b, 2]] -- WUT
notice( [ {a => 1}, {b => 2}, 2 ] + [{b => 2}] ) # [{a => 1}, {b => 2}, 2, {b => 2}] -- ok that's more like it