fastruby 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,115 +0,0 @@
1
- require "fastruby"
2
-
3
- describe FastRuby, "fastruby" do
4
- class ::N1
5
- fastruby "
6
- def bar(cc)
7
- cc.call(75)
8
- end
9
-
10
- def foo
11
- callcc do |cc|
12
- bar(cc)
13
- end
14
- end
15
- "
16
- end
17
-
18
- it "should execute callcc on fastruby" do
19
- ::N1.new.foo.should be == 75
20
- end
21
-
22
- class ::N2
23
- def bar(cc)
24
- cc.call(76)
25
- end
26
-
27
- fastruby "
28
- def foo
29
- callcc do |cc|
30
- bar(cc)
31
- end
32
- end
33
- "
34
- end
35
-
36
- it "should execute callcc from ruby" do
37
- ::N2.new.foo.should be == 76
38
- end
39
-
40
- class ::N3
41
- fastruby "
42
- def foo(n_)
43
- n = n_
44
-
45
- val = 0
46
- cc = nil
47
-
48
- x = callcc{|c| cc = c; nil}
49
-
50
- val = val + x if x
51
- n = n - 1
52
-
53
- cc.call(n) if n > 0
54
-
55
- val
56
- end
57
- "
58
- end
59
-
60
- it "should execute callcc from ruby using local variables" do
61
- ::N3.new.foo(4).should be == 6
62
- end
63
-
64
- class ::N4
65
- fastruby "
66
- def foo(n_)
67
- $n = n_
68
-
69
- $val = 0
70
- c = 0
71
-
72
-
73
- x = callcc{|c| $cc_n4 = c; nil}
74
-
75
- $val = $val + x if x
76
- $n = $n - 1
77
-
78
- $cc_n4.call($n) if $n > 0
79
-
80
- $val
81
- end
82
- "
83
- end
84
-
85
- it "should execute callcc from ruby using global variables" do
86
- ::N4.new.foo(4).should be == 6
87
- end
88
-
89
- class ::N5
90
- fastruby "
91
- def foo(n_)
92
- $n = n_
93
-
94
- $val = 0
95
- c = 0
96
- u = nil
97
-
98
- x = callcc{|c| $cc_n4 = c; u = 44; nil}
99
-
100
- $val = $val + x if x
101
- $n = $n - 1
102
-
103
- $cc_n4.call($n) if $n > 0
104
-
105
- u
106
- end
107
- "
108
- end
109
-
110
- it "should execute callcc loops and preserve local variables" do
111
- ::N5.new.foo(4).should be == 44
112
- end
113
-
114
-
115
- end