Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 101 lines (81 sloc) 2.009 kb
07d3202 added more tests
Allen Otis authored
1 def raiseErr
2 raise 'ERR'
3 end
4
23077da block_spec.rb , comment out two cases that give compile errors.
Allen Otis authored
5 a = 90
6 p = Proc.new { | y, *x | a = x[0] }
7 p.call
8 unless a.equal?(nil) then raiseErr end
9
10 a = 89
11 p = Proc.new { | *x | a = x[0] }
12 p.call
13 unless a.equal?(nil) then raiseErr end
14
15 a = 88
16 p = Proc.new { | x | a = x }
17 p.call
18 unless a.equal?(nil) then raiseErr end
19
20 a = 87
314217a Fix problems in Proc , [] invocation of a block
Allen Otis authored
21 b = 87
22 p = Proc.new { | x , y | a = x ; b = y }
23077da block_spec.rb , comment out two cases that give compile errors.
Allen Otis authored
23 p.call
24 unless a.equal?(nil) then raiseErr end
314217a Fix problems in Proc , [] invocation of a block
Allen Otis authored
25 unless b.equal?(nil) then raiseErr end
26
27 a = [99,98]
28 p[*a]
29 unless a.equal?(99) then raiseErr end
30 unless b.equal?(98) then raiseErr end
23077da block_spec.rb , comment out two cases that give compile errors.
Allen Otis authored
31
b0a766f reimplement Class>>name as needed in Ruby classes.
Allen Otis authored
32 a = [77,66]
73ef944 Added test for arity()
Peter McLain authored
33 p[*a] # coverage for ticket 132
b0a766f reimplement Class>>name as needed in Ruby classes.
Allen Otis authored
34 unless a.equal?(77) then raiseErr end
35 unless b.equal?(66) then raiseErr end
36
07d3202 added more tests
Allen Otis authored
37 def proc_from
38 # this form not supported
73ef944 Added test for arity()
Peter McLain authored
39 Proc.new
07d3202 added more tests
Allen Otis authored
40 end
41
42 def proc_fromA(&b)
73ef944 Added test for arity()
Peter McLain authored
43 Proc.new(&b)
07d3202 added more tests
Allen Otis authored
44 end
45 def proc_fromB(&b)
b0a766f reimplement Class>>name as needed in Ruby classes.
Allen Otis authored
46 begin
73ef944 Added test for arity()
Peter McLain authored
47 p = Proc.new(b)
b0a766f reimplement Class>>name as needed in Ruby classes.
Allen Otis authored
48 rescue Exception
49 # expect Gemstone error 2111
50 p = 999
51 else
73ef944 Added test for arity()
Peter McLain authored
52 raise 'ERR'
b0a766f reimplement Class>>name as needed in Ruby classes.
Allen Otis authored
53 end
54 p
07d3202 added more tests
Allen Otis authored
55 end
56
57 p = Proc.new { "hello" }
58 r = p.call
73ef944 Added test for arity()
Peter McLain authored
59 unless r == "hello" then raiseErr end
60
07d3202 added more tests
Allen Otis authored
61 # p = proc_from # not supported yet
62
63 p = proc_fromA { "goodbye" }
64 r = p.call
73ef944 Added test for arity()
Peter McLain authored
65 unless r == "goodbye" then raiseErr end
07d3202 added more tests
Allen Otis authored
66
67 p = proc_fromB { "notime" }
b0a766f reimplement Class>>name as needed in Ruby classes.
Allen Otis authored
68 unless p == 999 then raiseErr end
07d3202 added more tests
Allen Otis authored
69
23077da block_spec.rb , comment out two cases that give compile errors.
Allen Otis authored
70 a = 0
71 p = Proc.new { | x | a = a + x }
72 p.call(30)
73 unless a == 30 then raiseErr end
74
75 p = Proc.new { | x | a = x }
76 p.call
77 unless a.equal?(nil) then raiseErr end
78
79
73ef944 Added test for arity()
Peter McLain authored
80 # Ensure passed blocks have arity defined
81 def test_arity(expected, msg, &block)
82 actual = block.arity
83 raise "test_arity: #{msg}: expected #{expected} actual: #{actual}" unless actual == expected
84 end
85
86 test_arity(-1, "A") { true }
87 test_arity(1, "A") { |x| true }
88 test_arity(2, "A") { |x,y| true }
39467f1 Changes to bootstrap and libraries for compatiblity with Ruby 1.8.7.
Allen Otis authored
89
90 # coverage added for 1.8.7 syntax changes (last arg to a block can have &)
91 #
92 sel = :call
93 pa = Proc.new {|&blk| blk.send( sel ) }
94 x = pa.send( sel ) {150 + 100 }
95 unless x == 250 ; raise 'error'; end
96
97 pb = Proc.new {|aa, &blk| blk.call(aa, 5) }
98 y = pb.call(300 ) {|m,n| m + n }
99 unless y == 305 ; raise 'error'; end
100 true
Something went wrong with that request. Please try again.