-
Notifications
You must be signed in to change notification settings - Fork 59
/
tc_attr_rewrite.rb
69 lines (59 loc) · 1.11 KB
/
tc_attr_rewrite.rb
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
require './test_common'
class TestCols < Minitest::Test
class SimpleCols
include Bud
state do
table :t1
table :t2
end
bootstrap do
t1 << [1,2]
end
bloom do
t2 <= t1 {|t| [t.key, t.val]}
end
end
def test_simple_cols
program = SimpleCols.new
program.tick
assert_equal([[1,2]], program.t2.to_a)
end
class NestedCols
include Bud
state do
table :t1
table :t2
table :t3
end
bootstrap do
t1 << [1,2]
t3 << [1,3]
end
bloom do
t2 <= t1 {|t| [t.key, t.val] if t3.each{|x| t.key == x.key}}
end
end
def test_nested_cols
program = NestedCols.new
program.tick
assert_equal([[1,2]], program.t2.to_a)
end
class BadNestedCols
include Bud
state do
table :t1
table :t2
table :t3, [:val, :key]
end
bootstrap do
t1 << [1,2]
t3 << [1,3]
end
bloom do
t2 <= t1 {|t| [t.key, t.val] if t3.each{|t| t.key == t.val}}
end
end
def test_bad_nested_cols
assert_raises(Bud::CompileError) {BadNestedCols.new}
end
end