-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumeric_test.rb
More file actions
69 lines (60 loc) · 2.48 KB
/
Numeric_test.rb
File metadata and controls
69 lines (60 loc) · 2.48 KB
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_relative "test_helper"
class NumericInstanceTest < Test::Unit::TestCase
include TestHelper
testing 'Numeric'
def test_real
assert_send_type '() -> Integer', 1, :real
assert_send_type '() -> Float', 1.0, :real
assert_send_type '() -> Rational', 1r, :real
end
def test_real?
assert_send_type '() -> true', 1, :real?
assert_send_type '() -> true', 1.0, :real?
assert_send_type '() -> true', 1r, :real?
end
def test_zero?
assert_send_type '() -> bool', 0, :zero?
assert_send_type '() -> bool', 1r, :zero?
end
def test_angle
assert_send_type '() -> 0', 1, :angle
assert_send_type '() -> Float', -1, :angle
assert_send_type '() -> Float', Float::NAN, :angle
end
def test_abs2
assert_send_type '() -> Integer', 1, :abs2
assert_send_type '() -> Float', 1.0, :abs2
assert_send_type '() -> Rational', 1r, :abs2
end
def test_to_c
assert_send_type '() -> Complex', 1, :to_c
assert_send_type '() -> Complex', 1.0, :to_c
assert_send_type '() -> Complex', 1r, :to_c
end
def test_step
assert_send_type '() -> Enumerator::ArithmeticSequence',
1, :step
assert_send_type '() { (Integer) -> void } -> Integer',
1, :step do |i| break_from_block i end
assert_send_type '(Float) -> Enumerator::ArithmeticSequence',
1, :step, 1.5
assert_send_type '(Float) { (Float) -> void } -> Integer',
1, :step, 1.5 do |i| break_from_block i end
assert_send_type '(Integer, Float) -> Enumerator::ArithmeticSequence',
1r, :step, 2, 0.2
assert_send_type '(Integer, Float) { (Float) -> void } -> Rational',
1r, :step, 2, 0.2 do |i| end
assert_send_type '(to: Rational) -> Enumerator::ArithmeticSequence',
1, :step, to: 2r
assert_send_type '(to: Rational) { (Integer) -> void } -> Integer',
1, :step, to: 2r do |i| end
assert_send_type '(by: Float) -> Enumerator::ArithmeticSequence',
1, :step, by: 0.2
assert_send_type '(by: Float) { (Float) -> void } -> Rational',
1, :step, by: 0.2 do |i| break_from_block i end
assert_send_type '(to: Rational, by: Float) -> Enumerator::ArithmeticSequence',
1, :step, to: 3r, by: 0.2
assert_send_type '(to: Rational, by: Float) { (Float) -> void } -> Rational',
1, :step, to: 3r, by: 0.2 do |i| break_from_block i end
end
end