public
Description: RSpec-style specification for the Ruby programming language
Homepage: http://rubyspec.org
Clone URL: git://github.com/brixen/rubyspec.git
Search Repo:
Merge branch 'master' of git@github.com:brixen/rubyspec
nicksieger (author)
Wed May 14 10:37:52 -0700 2008
commit  3722b9e624d7bbf62c378b8d4ac92b4b90e8d43a
tree    b84a3bea605481cd72eed0ed64d1e565d06b549e
parent  799fd9dc4e9b6d731d4d789687ee46d2949c3270 parent  7d2e72fbd3342412f2a2e48de859423a519604cd
...
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -1,3 +1,23 @@
0
 require File.dirname(__FILE__) + '/../../spec_helper'
0
 require File.dirname(__FILE__) + '/fixtures/classes'
0
+
0
+describe "Module#protected" do
0
+
0
+ before :each do
0
+ class << ModuleSpecs::Parent
0
+ def protected_method_1; 5; end
0
+ end
0
+ end
0
+
0
+ it "makes an existing class method protected" do
0
+ ModuleSpecs::Parent.protected_method_1.should == 5
0
+
0
+ class << ModuleSpecs::Parent
0
+ protected :protected_method_1
0
+ end
0
+
0
+ lambda { ModuleSpecs::Parent.protected_method_1 }.should raise_error(NoMethodError)
0
+ end
0
+
0
+end
...
1
 
2
3
4
5
 
 
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
12
...
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
0
@@ -1,13 +1,84 @@
0
 require File.dirname(__FILE__) + '/../../../spec_helper'
0
+require File.dirname(__FILE__) + '/fixtures/classes'
0
 require 'complex'
0
 
0
 describe "Math#acos" do
0
- it "needs to be reviewed for spec completeness" do
0
+ before(:each) do
0
+ @im = IncludesMath.new
0
   end
0
+
0
+ it "should be private" do
0
+ IncludesMath.private_instance_methods.should include("acos")
0
+ end
0
+
0
+ it "returns the arccosine of the passed argument" do
0
+ @im.send(:acos, 1).should be_close(0.0, TOLERANCE)
0
+ @im.send(:acos, 0).should be_close(1.5707963267949, TOLERANCE)
0
+ @im.send(:acos, -1).should be_close(Math::PI,TOLERANCE)
0
+ end
0
+
0
+ it "returns a Complex representation if the passed argument is greater than 1.0" do
0
+ @im.send(:acos, 1.0001).should be_close(Complex(0.0, 0.0141420177752494), TOLERANCE)
0
+ end
0
+
0
+ it "returns a Complex representation if the passed argument is less than -1.0" do
0
+ @im.send(:acos, -1.0001).should be_close(Complex(3.14159265358979, -0.0141420177752495), TOLERANCE)
0
+ end
0
 end
0
 
0
 describe "Math#acos!" do
0
- it "needs to be reviewed for spec completeness" do
0
+ before(:each) do
0
+ @im = IncludesMath.new
0
+ end
0
+
0
+ it "should be private" do
0
+ IncludesMath.private_instance_methods.should include("acos!")
0
+ end
0
+
0
+ it "returns the arccosine of the argument" do
0
+ @im.send(:acos!, 1).should be_close(0.0, TOLERANCE)
0
+ @im.send(:acos!, 0).should be_close(1.5707963267949, TOLERANCE)
0
+ @im.send(:acos!, -1).should be_close(Math::PI,TOLERANCE)
0
+ end
0
+
0
+ it "raises an Errno::EDOM if the argument is greater than 1.0" do
0
+ lambda { @im.send(:acos!, 1.0001) }.should raise_error(Errno::EDOM)
0
+ end
0
+
0
+ it "raises an Errno::EDOM if the argument is less than -1.0" do
0
+ lambda { @im.send(:acos!, -1.0001) }.should raise_error(Errno::EDOM)
0
+ end
0
+end
0
+
0
+describe "Math.acos" do
0
+ it "returns the arccosine of the passed argument" do
0
+ Math.acos(1).should be_close(0.0, TOLERANCE)
0
+ Math.acos(0).should be_close(1.5707963267949, TOLERANCE)
0
+ Math.acos(-1).should be_close(Math::PI,TOLERANCE)
0
+ end
0
+
0
+ it "returns a Complex representation if the passed argument is greater than 1.0" do
0
+ Math.acos(1.0001).should be_close(Complex(0.0, 0.0141420177752494), TOLERANCE)
0
+ end
0
+
0
+ it "returns a Complex representation if the passed argument is less than -1.0" do
0
+ Math.acos(-1.0001).should be_close(Complex(3.14159265358979, -0.0141420177752495), TOLERANCE)
0
+ end
0
+end
0
+
0
+describe "Math.acos!" do
0
+ it "returns the arccosine of the argument" do
0
+ Math.acos!(1).should be_close(0.0, TOLERANCE)
0
+ Math.acos!(0).should be_close(1.5707963267949, TOLERANCE)
0
+ Math.acos!(-1).should be_close(Math::PI,TOLERANCE)
0
+ end
0
+
0
+ it "raises an Errno::EDOM if the argument is greater than 1.0" do
0
+ lambda { Math.acos!(1.0001) }.should raise_error(Errno::EDOM)
0
+ end
0
+
0
+ it "raises an Errno::EDOM if the argument is less than -1.0" do
0
+ lambda { Math.acos!(-1.0001) }.should raise_error(Errno::EDOM)
0
   end
0
 end
...
10
11
12
 
 
 
 
 
 
 
 
 
 
...
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -10,4 +10,14 @@
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
0
+
0
+describe "Math.acosh" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
+describe "Math.acosh!" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
...
1
2
3
 
 
 
 
 
4
5
6
7
8
9
 
 
 
 
 
 
10
11
12
...
1
2
3
4
5
6
7
8
9
10
11
12
13
 
14
15
16
17
18
19
20
21
22
0
@@ -1,12 +1,22 @@
0
 require File.dirname(__FILE__) + '/../../../spec_helper'
0
 require 'complex'
0
 
0
+describe "Math#asin" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
 describe "Math#asin!" do
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
0
 
0
-describe "Math#asin" do
0
+describe "Math.asin" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
+describe "Math.asin!" do
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
...
10
11
12
 
 
 
 
 
 
 
 
 
 
...
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -10,4 +10,14 @@
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
0
+
0
+describe "Math.asinh" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
+describe "Math.asinh!" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
...
10
11
12
 
 
 
 
 
 
 
 
 
 
...
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -10,4 +10,14 @@
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
0
+
0
+describe "Math.atan2" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
+describe "Math.atan2!" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
...
1
2
3
 
 
 
 
 
4
5
6
7
8
9
 
 
 
 
 
 
10
11
12
...
1
2
3
4
5
6
7
8
9
10
11
12
13
 
14
15
16
17
18
19
20
21
22
0
@@ -1,12 +1,22 @@
0
 require File.dirname(__FILE__) + '/../../../spec_helper'
0
 require 'complex'
0
 
0
+describe "Math#atan" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
 describe "Math#atan!" do
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
0
 
0
-describe "Math#atan" do
0
+describe "Math.atan" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
+describe "Math.atan!" do
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
...
1
2
3
 
 
 
 
 
4
5
6
7
8
9
 
 
 
 
 
 
10
11
12
...
1
2
3
4
5
6
7
8
9
10
11
12
13
 
14
15
16
17
18
19
20
21
22
0
@@ -1,12 +1,22 @@
0
 require File.dirname(__FILE__) + '/../../../spec_helper'
0
 require 'complex'
0
 
0
+describe "Math#atanh" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
 describe "Math#atanh!" do
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
0
 
0
-describe "Math#atanh" do
0
+describe "Math.atanh" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
+describe "Math.atanh!" do
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
...
1
 
2
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
5
 
 
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
12
...
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
70
71
72
73
0
@@ -1,13 +1,74 @@
0
 require File.dirname(__FILE__) + '/../../../spec_helper'
0
+require File.dirname(__FILE__) + '/fixtures/classes'
0
 require 'complex'
0
 
0
+describe "Math#cos" do
0
+ before(:each) do
0
+ @im = IncludesMath.new
0
+ end
0
+
0
+ it "should be private" do
0
+ IncludesMath.private_instance_methods.should include("cos")
0
+ end
0
+
0
+ it "returns the cosine of the argument expressed in radians" do
0
+ @im.send(:cos, Math::PI).should be_close(-1.0, TOLERANCE)
0
+ @im.send(:cos, 0).should be_close(1.0, TOLERANCE)
0
+ @im.send(:cos, Math::PI/2).should be_close(0.0, TOLERANCE)
0
+ @im.send(:cos, 3*Math::PI/2).should be_close(0.0, TOLERANCE)
0
+ @im.send(:cos, 2*Math::PI).should be_close(1.0, TOLERANCE)
0
+
0
+ @im.send(:cos, Complex(0, Math::PI)).should be_close(Complex(11.5919532755215, 0.0), TOLERANCE)
0
+ @im.send(:cos, Complex(3, 4)).should be_close(Complex(-27.0349456030742, -3.85115333481178), TOLERANCE)
0
+ end
0
+end
0
+
0
 describe "Math#cos!" do
0
- it "needs to be reviewed for spec completeness" do
0
+ before(:each) do
0
+ @im = IncludesMath.new
0
   end
0
+
0
+ it "should be private" do
0
+ IncludesMath.private_instance_methods.should include("cos!")
0
+ end
0
+
0
+ it "returns the cosine of the argument expressed in radians" do
0
+ @im.send(:cos!, Math::PI).should be_close(-1.0, TOLERANCE)
0
+ @im.send(:cos!, 0).should be_close(1.0, TOLERANCE)
0
+ @im.send(:cos!, Math::PI/2).should be_close(0.0, TOLERANCE)
0
+ @im.send(:cos!, 3*Math::PI/2).should be_close(0.0, TOLERANCE)
0
+ @im.send(:cos!, 2*Math::PI).should be_close(1.0, TOLERANCE)
0
+ end
0
+
0
+ it "raises a TypeError when passed a Complex number" do
0
+ lambda { @im.send(:cos!, Complex(3, 4)) }.should raise_error(TypeError)
0
+ end
0
 end
0
 
0
-describe "Math#cos" do
0
- it "needs to be reviewed for spec completeness" do
0
+describe "Math.cos" do
0
+ it "returns the cosine of the argument expressed in radians" do
0
+ Math.cos(Math::PI).should be_close(-1.0, TOLERANCE)
0
+ Math.cos(0).should be_close(1.0, TOLERANCE)
0
+ Math.cos(Math::PI/2).should be_close(0.0, TOLERANCE)
0
+ Math.cos(3*Math::PI/2).should be_close(0.0, TOLERANCE)
0
+ Math.cos(2*Math::PI).should be_close(1.0, TOLERANCE)
0
+
0
+ Math.cos(Complex(0, Math::PI)).should be_close(Complex(11.5919532755215, 0.0), TOLERANCE)
0
+ Math.cos(Complex(3, 4)).should be_close(Complex(-27.0349456030742, -3.85115333481178), TOLERANCE)
0
+ end
0
+end
0
+
0
+describe "Math.cos!" do
0
+ it "returns the cosine of the argument expressed in radians" do
0
+ Math.cos!(Math::PI).should be_close(-1.0, TOLERANCE)
0
+ Math.cos!(0).should be_close(1.0, TOLERANCE)
0
+ Math.cos!(Math::PI/2).should be_close(0.0, TOLERANCE)
0
+ Math.cos!(3*Math::PI/2).should be_close(0.0, TOLERANCE)
0
+ Math.cos!(2*Math::PI).should be_close(1.0, TOLERANCE)
0
+ end
0
+
0
+ it "raises a TypeError when passed a Complex number" do
0
+ lambda { Math.cos!(Complex(3, 4)) }.should raise_error(TypeError)
0
   end
0
 end
...
10
11
12
 
 
 
 
 
 
 
 
 
 
...
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -10,4 +10,14 @@
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
0
+
0
+describe "Math.cosh" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
+describe "Math.cosh!" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
...
1
 
2
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
5
 
 
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
12
...
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
0
@@ -1,13 +1,70 @@
0
 require File.dirname(__FILE__) + '/../../../spec_helper'
0
+require File.dirname(__FILE__) + '/fixtures/classes'
0
 require 'complex'
0
 
0
+describe "Math#exp" do
0
+ before(:each) do
0
+ @im = IncludesMath.new
0
+ end
0
+
0
+ it "should be private" do
0
+ IncludesMath.private_instance_methods.should include("exp")
0
+ end
0
+
0
+ it "returns the base-e exponential of the passed argument" do
0
+ @im.send(:exp, 0.0).should == 1.0
0
+ @im.send(:exp, -0.0).should == 1.0
0
+ @im.send(:exp, -1.8).should be_close(0.165298888221587, TOLERANCE)
0
+ @im.send(:exp, 1.25).should be_close(3.49034295746184, TOLERANCE)
0
+
0
+ @im.send(:exp, Complex(0, 0)).should == Complex(1.0, 0.0)
0
+ @im.send(:exp, Complex(1, 3)).should be_close(Complex(-2.69107861381979, 0.383603953541131), TOLERANCE)
0
+ end
0
+end
0
+
0
 describe "Math#exp!" do
0
- it "needs to be reviewed for spec completeness" do
0
+ before(:each) do
0
+ @im = IncludesMath.new
0
   end
0
+
0
+ it "should be private" do
0
+ IncludesMath.private_instance_methods.should include("exp!")
0
+ end
0
+
0
+ it "returns the base-e exponential of the passed argument" do
0
+ @im.send(:exp!, 0.0).should == 1.0
0
+ @im.send(:exp!, -0.0).should == 1.0
0
+ @im.send(:exp!, -1.8).should be_close(0.165298888221587, TOLERANCE)
0
+ @im.send(:exp!, 1.25).should be_close(3.49034295746184, TOLERANCE)
0
+ end
0
+
0
+ it "raises a TypeError when passed a Complex number" do
0
+ lambda { @im.send(:exp!, Complex(1, 3)) }.should raise_error(TypeError)
0
+ end
0
 end
0
 
0
-describe "Math#exp" do
0
- it "needs to be reviewed for spec completeness" do
0
+describe "Math.exp" do
0
+ it "returns the base-e exponential of the passed argument" do
0
+ Math.exp(0.0).should == 1.0
0
+ Math.exp(-0.0).should == 1.0
0
+ Math.exp(-1.8).should be_close(0.165298888221587, TOLERANCE)
0
+ Math.exp(1.25).should be_close(3.49034295746184, TOLERANCE)
0
+
0
+ Math.exp(Complex(0, 0)).should == Complex(1.0, 0.0)
0
+ Math.exp(Complex(1, 3)).should be_close(Complex(-2.69107861381979, 0.383603953541131), TOLERANCE)
0
+ end
0
+end
0
+
0
+describe "Math.exp!" do
0
+ it "returns the base-e exponential of the passed argument" do
0
+ Math.exp!(0.0).should == 1.0
0
+ Math.exp!(-0.0).should == 1.0
0
+ Math.exp!(-1.8).should be_close(0.165298888221587, TOLERANCE)
0
+ Math.exp!(1.25).should be_close(3.49034295746184, TOLERANCE)
0
+ end
0
+
0
+ it "raises a TypeError when passed a Complex number" do
0
+ lambda { Math.exp!(Complex(1, 3)) }.should raise_error(TypeError)
0
   end
0
 end
...
 
 
 
...
1
2
3
0
@@ -1 +1,4 @@
0
+class IncludesMath
0
+ include Math
0
+end
...
10
11
12
 
 
 
 
 
 
 
 
 
 
...
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -10,4 +10,14 @@
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
0
+
0
+describe "Math.log10" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
+describe "Math.log10!" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
...
1
2
3
 
 
 
 
 
4
5
6
7
8
9
 
 
 
 
 
 
10
11
12
...
1
2
3
4
5
6
7
8
9
10
11
12
13
 
14
15
16
17
18
19
20
21
22
0
@@ -1,12 +1,22 @@
0
 require File.dirname(__FILE__) + '/../../../spec_helper'
0
 require 'complex'
0
 
0
+describe "Math#log" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
 describe "Math#log!" do
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
0
 
0
-describe "Math#log" do
0
+describe "Math.log" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
+describe "Math.log!" do
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
...
1
 
2
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
5
 
 
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
12
...
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
70
71
72
73
0
@@ -1,13 +1,74 @@
0
 require File.dirname(__FILE__) + '/../../../spec_helper'
0
+require File.dirname(__FILE__) + '/fixtures/classes'
0
 require 'complex'
0
 
0
+describe "Math#sin" do
0
+ before(:each) do
0
+ @im = IncludesMath.new
0
+ end
0
+
0
+ it "should be private" do
0
+ IncludesMath.private_instance_methods.should include("cos")
0
+ end
0
+
0
+ it "returns the sine of the passed argument expressed in radians" do
0
+ @im.send(:sin, Math::PI).should be_close(0.0, TOLERANCE)
0
+ @im.send(:sin, 0).should be_close(0.0, TOLERANCE)
0
+ @im.send(:sin, Math::PI/2).should be_close(1.0, TOLERANCE)
0
+ @im.send(:sin, 3*Math::PI/2).should be_close(-1.0, TOLERANCE)
0
+ @im.send(:sin, 2*Math::PI).should be_close(0.0, TOLERANCE)
0
+
0
+ @im.send(:sin, Complex(0, Math::PI)).should be_close(Complex(0.0, 11.5487393572577), TOLERANCE)
0
+ @im.send(:sin, Complex(3, 4)).should be_close(Complex(3.85373803791938, -27.0168132580039), TOLERANCE)
0
+ end
0
+end
0
+
0
 describe "Math#sin!" do
0
- it "needs to be reviewed for spec completeness" do
0
+ before(:each) do
0
+ @im = IncludesMath.new
0
   end
0
+
0
+ it "should be private" do
0
+ IncludesMath.private_instance_methods.should include("cos!")
0
+ end
0
+
0
+ it "returns the sine of the passed argument expressed in radians" do
0
+ @im.send(:sin!, Math::PI).should be_close(0.0, TOLERANCE)
0
+ @im.send(:sin!, 0).should be_close(0.0, TOLERANCE)
0
+ @im.send(:sin!, Math::PI/2).should be_close(1.0, TOLERANCE)
0
+ @im.send(:sin!, 3*Math::PI/2).should be_close(-1.0, TOLERANCE)
0
+ @im.send(:sin!, 2*Math::PI).should be_close(0.0, TOLERANCE)
0
+ end
0
+
0
+ it "raises a TypeError when passed a Complex number" do
0
+ lambda { @im.send(:sin!, Complex(4, 5)) }.should raise_error(TypeError)
0
+ end
0
 end
0
 
0
-describe "Math#sin" do
0
- it "needs to be reviewed for spec completeness" do
0
+describe "Math.sin" do
0
+ it "returns the sine of the passed argument expressed in radians" do
0
+ Math.sin(Math::PI).should be_close(0.0, TOLERANCE)
0
+ Math.sin(0).should be_close(0.0, TOLERANCE)
0
+ Math.sin(Math::PI/2).should be_close(1.0, TOLERANCE)
0
+ Math.sin(3*Math::PI/2).should be_close(-1.0, TOLERANCE)
0
+ Math.sin(2*Math::PI).should be_close(0.0, TOLERANCE)
0
+
0
+ Math.sin(Complex(0, Math::PI)).should be_close(Complex(0.0, 11.5487393572577), TOLERANCE)
0
+ Math.sin(Complex(3, 4)).should be_close(Complex(3.85373803791938, -27.0168132580039), TOLERANCE)
0
+ end
0
+end
0
+
0
+describe "Math.sin!" do
0
+ it "returns the sine of the passed argument expressed in radians" do
0
+ Math.sin(Math::PI).should be_close(0.0, TOLERANCE)
0
+ Math.sin(0).should be_close(0.0, TOLERANCE)
0
+ Math.sin(Math::PI/2).should be_close(1.0, TOLERANCE)
0
+ Math.sin(3*Math::PI/2).should be_close(-1.0, TOLERANCE)
0
+ Math.sin(2*Math::PI).should be_close(0.0, TOLERANCE)
0
+ end
0
+
0
+ it "raises a TypeError when passed a Complex number" do
0
+ lambda { Math.sin!(Complex(4, 5)) }.should raise_error(TypeError)
0
   end
0
 end
...
10
11
12
 
 
 
 
 
 
 
 
 
 
...
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -10,4 +10,14 @@
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
0
+
0
+describe "Math.sinh" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
+describe "Math.sinh!" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
...
1
 
2
3
4
5
 
 
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
12
...
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
0
@@ -1,13 +1,86 @@
0
 require File.dirname(__FILE__) + '/../../../spec_helper'
0
+require File.dirname(__FILE__) + '/fixtures/classes'
0
 require 'complex'
0
 
0
 describe "Math#sqrt" do
0
- it "needs to be reviewed for spec completeness" do
0
+ before(:each) do
0
+ @im = IncludesMath.new
0
   end
0
+
0
+ it "should be private" do
0
+ IncludesMath.private_instance_methods.should include("sqrt")
0
+ end
0
+
0
+ it "returns the square root of the passed argument when it is positive" do
0
+ @im.send(:sqrt, 4).should == 2
0
+ @im.send(:sqrt, 19.36).should == 4.4
0
+ end
0
+
0
+ it "returns the square root of the passed argument when it is negative" do
0
+ @im.send(:sqrt, -4).should == Complex(0, 2.0)
0
+ @im.send(:sqrt, -19.36).should == Complex(0, 4.4)
0
+ end
0
+
0
+ it "returns the square root of the passed argument when it is a Complex number" do
0
+ @im.send(:sqrt, Complex(4, 5)).should be_close(Complex(2.2806933416653, 1.09615788950152), TOLERANCE)
0
+ @im.send(:sqrt, Complex(4, -5)).should be_close(Complex(2.2806933416653, -1.09615788950152), TOLERANCE)
0
+ end
0
 end
0
 
0
 describe "Math#sqrt!" do
0
- it "needs to be reviewed for spec completeness" do
0
+ before(:each) do
0
+ @im = IncludesMath.new
0
+ end
0
+
0
+ it "should be private" do
0
+ IncludesMath.private_instance_methods.should include("sqrt!")
0
+ end
0
+
0
+ it "returns the square root of the passed argument when it is positive" do
0
+ @im.send(:sqrt!, 4).should == 2
0
+ @im.send(:sqrt!, 19.36).should == 4.4
0
+ end
0
+
0
+ it "raises Errno::EDOM when the passed argument is negative" do
0
+ lambda { @im.send(:sqrt!, -4) }.should raise_error(Errno::EDOM)
0
+ lambda { @im.send(:sqrt!, -19.36) }.should raise_error(Errno::EDOM)
0
+ end
0
+
0
+ it "raises a TypeError when passed a Complex number" do
0
+ lambda { @im.send(:sqrt!, Complex(4, 5)) }.should raise_error(TypeError)
0
+ end
0
+end
0
+
0
+describe "Math.sqrt" do
0
+ it "returns the square root of the passed argument when it is positive" do
0
+ Math.sqrt(4).should == 2
0
+ Math.sqrt(19.36).should == 4.4
0
+ end
0
+
0
+ it "returns the square root of the passed argument when it is negative" do
0
+ Math.sqrt(-4).should == Complex(0, 2.0)
0
+ Math.sqrt(-19.36).should == Complex(0, 4.4)
0
+ end
0
+
0
+ it "returns the square root of the passed argument when it is a Complex number" do
0
+ Math.sqrt(Complex(4, 5)).should be_close(Complex(2.2806933416653, 1.09615788950152), TOLERANCE)
0
+ Math.sqrt(Complex(4, -5)).should be_close(Complex(2.2806933416653, -1.09615788950152), TOLERANCE)
0
+ end
0
+end
0
+
0
+describe "Math.sqrt!" do
0
+ it "returns the square root of the passed argument when it is positive" do
0
+ Math.sqrt!(4).should == 2
0
+ Math.sqrt!(19.36).should == 4.4
0
+ end
0
+
0
+ it "raises Errno::EDOM when the passed argument is negative" do
0
+ lambda { Math.sqrt!(-4) }.should raise_error(Errno::EDOM)
0
+ lambda { Math.sqrt!(-19.36) }.should raise_error(Errno::EDOM)
0
+ end
0
+
0
+ it "raises a TypeError when passed a Complex number" do
0
+ lambda { Math.sqrt!(Complex(4, 5)) }.should raise_error(TypeError)
0
   end
0
 end
...
10
11
12
 
 
 
 
 
 
 
 
 
 
...
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -10,4 +10,14 @@
0
   it "needs to be reviewed for spec completeness" do
0
   end
0
 end
0
+
0
+describe "Math.tan" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end
0
+
0
+describe "Math.tan!" do
0
+ it "needs to be reviewed for spec completeness" do
0
+ end
0
+end