iba 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +674 -0
- data/COPYING.LESSER +165 -0
- data/LICENSE +16 -0
- data/README.rdoc +59 -0
- data/Rakefile +3 -0
- data/lib/iba.rb +182 -0
- data/tasks/notes.rake +122 -0
- data/tasks/setup.rb +6 -0
- data/tasks/test.rake +14 -0
- data/test/analyse_test.rb +42 -0
- data/test/assert_test.rb +51 -0
- data/test/call_test.rb +18 -0
- data/test/display_test.rb +48 -0
- data/test/test_helper.rb +12 -0
- metadata +89 -0
data/tasks/setup.rb
ADDED
data/tasks/test.rake
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require File.expand_path('test_helper.rb', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
# Test how the combinator analyses the parsed block contents.
|
|
4
|
+
class AnalyseTest < Test::Unit::TestCase
|
|
5
|
+
def test_empty_block
|
|
6
|
+
assert_equal "empty block", combinator { }.analyse
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_variable
|
|
10
|
+
foo = 23
|
|
11
|
+
assert_equal "foo is 23", combinator { foo }.analyse
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_operator_equals
|
|
15
|
+
foo = 42
|
|
16
|
+
bar = 23
|
|
17
|
+
assert_equal "(foo == bar) is false\nfoo is 42, bar is 23",
|
|
18
|
+
combinator { foo == bar }.analyse
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_operator_equals_literal
|
|
22
|
+
foo = 42
|
|
23
|
+
assert_equal "(foo == 23) is false\nfoo is 42",
|
|
24
|
+
combinator { foo == 23 }.analyse
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_string_variable
|
|
28
|
+
foo = "blub"
|
|
29
|
+
assert_equal "foo is \"blub\"", combinator { foo }.analyse
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_object_variable
|
|
33
|
+
foo = Object.new
|
|
34
|
+
insp = foo.inspect
|
|
35
|
+
assert_equal "foo is #{insp}", combinator { foo }.analyse
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_literal
|
|
39
|
+
assert_equal "23 is 23", combinator { 23 }.analyse
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
data/test/assert_test.rb
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require File.expand_path('test_helper.rb', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
# Test behavior of overridden assert method.
|
|
4
|
+
class AssertTest < Test::Unit::TestCase
|
|
5
|
+
def test_simple_assert
|
|
6
|
+
assert { true }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_simple_failing_assert
|
|
10
|
+
begin
|
|
11
|
+
assert { false }
|
|
12
|
+
rescue Exception => e
|
|
13
|
+
assert_equal "false is false.", e.message
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_operator_equals_assert
|
|
18
|
+
foo = 24
|
|
19
|
+
begin
|
|
20
|
+
assert { foo == 23 }
|
|
21
|
+
rescue Exception => e
|
|
22
|
+
assert_equal "(foo == 23) is false\nfoo is 24.", e.message
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_assert_with_custom_message
|
|
27
|
+
foo = false
|
|
28
|
+
begin
|
|
29
|
+
assert("We want foo") { foo }
|
|
30
|
+
rescue Exception => e
|
|
31
|
+
assert_equal "We want foo.\nfoo is false.", e.message
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_original_assert
|
|
36
|
+
begin
|
|
37
|
+
assert false
|
|
38
|
+
rescue Exception => e
|
|
39
|
+
assert_equal "<false> is not true.", e.message
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_original_assert_with_custom_message
|
|
44
|
+
begin
|
|
45
|
+
assert false, "We want the truth"
|
|
46
|
+
rescue Exception => e
|
|
47
|
+
assert_equal "We want the truth.\n<false> is not true.", e.message
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
data/test/call_test.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require File.expand_path('test_helper.rb', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
# Test how the combinator calls the passed block.
|
|
4
|
+
class CallTest < Test::Unit::TestCase
|
|
5
|
+
def test_empty_combinator
|
|
6
|
+
assert_equal nil, combinator { }.call
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_variable
|
|
10
|
+
foo = 23
|
|
11
|
+
assert_equal 23, combinator { foo }.call
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_operator_call
|
|
15
|
+
foo = 23
|
|
16
|
+
assert_equal true, combinator { foo == 23 }.call
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require File.expand_path('test_helper.rb', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
# Test how the combinator displays the parsed block contents.
|
|
4
|
+
class DisplayTest < Test::Unit::TestCase
|
|
5
|
+
def test_empty_combinator
|
|
6
|
+
assert_equal "", combinator { }.to_s
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_literal
|
|
10
|
+
assert_equal "23", combinator { 23 }.to_s
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_method_calls
|
|
14
|
+
assert_equal "foo", combinator { foo }.to_s
|
|
15
|
+
assert_equal "foo.foo", combinator { foo.foo }.to_s
|
|
16
|
+
assert_equal "foo.foo(1)", combinator { foo.foo 1 }.to_s
|
|
17
|
+
assert_equal "foo(1)", combinator { foo 1 }.to_s
|
|
18
|
+
assert_equal "foo(bar)", combinator { foo bar }.to_s
|
|
19
|
+
assert_equal "foo(1).bar", combinator { foo(1).bar }.to_s
|
|
20
|
+
assert_equal "foo.foo.foo", combinator { foo.foo.foo }.to_s
|
|
21
|
+
assert_equal "foo(bar.baz)", combinator { foo bar.baz }.to_s
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_operators
|
|
25
|
+
assert_equal "(foo + 1)", combinator { foo + 1 }.to_s
|
|
26
|
+
assert_equal "(foo - 1)", combinator { foo - 1 }.to_s
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_operator_equals
|
|
30
|
+
assert_equal "(foo == 1)", combinator { foo == 1 }.to_s
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_array_index
|
|
34
|
+
assert_equal "foo[1]", combinator { foo[1] }.to_s
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_to_s_method
|
|
38
|
+
assert_equal "foo.to_s", combinator { foo.to_s }.to_s
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_operator_unary_minus
|
|
42
|
+
assert_equal "-foo", combinator { -foo }.to_s
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_operator_if_wont_work
|
|
46
|
+
assert_equal "bar", combinator { foo ? bar : baz }.to_s
|
|
47
|
+
end
|
|
48
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: iba
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 29
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 0
|
|
9
|
+
- 1
|
|
10
|
+
version: 0.0.1
|
|
11
|
+
platform: ruby
|
|
12
|
+
authors:
|
|
13
|
+
- Matijs van Zuijlen
|
|
14
|
+
autorequire:
|
|
15
|
+
bindir: bin
|
|
16
|
+
cert_chain: []
|
|
17
|
+
|
|
18
|
+
date: 2011-01-02 00:00:00 +01:00
|
|
19
|
+
default_executable:
|
|
20
|
+
dependencies: []
|
|
21
|
+
|
|
22
|
+
description: Asserts blocks, prints introspective failure messages.
|
|
23
|
+
email:
|
|
24
|
+
- matijs@matijs.net
|
|
25
|
+
executables: []
|
|
26
|
+
|
|
27
|
+
extensions: []
|
|
28
|
+
|
|
29
|
+
extra_rdoc_files:
|
|
30
|
+
- README.rdoc
|
|
31
|
+
- LICENSE
|
|
32
|
+
- COPYING.LESSER
|
|
33
|
+
- COPYING
|
|
34
|
+
files:
|
|
35
|
+
- lib/iba.rb
|
|
36
|
+
- test/analyse_test.rb
|
|
37
|
+
- test/test_helper.rb
|
|
38
|
+
- test/call_test.rb
|
|
39
|
+
- test/assert_test.rb
|
|
40
|
+
- test/display_test.rb
|
|
41
|
+
- tasks/test.rake
|
|
42
|
+
- tasks/setup.rb
|
|
43
|
+
- tasks/notes.rake
|
|
44
|
+
- COPYING.LESSER
|
|
45
|
+
- LICENSE
|
|
46
|
+
- README.rdoc
|
|
47
|
+
- Rakefile
|
|
48
|
+
- COPYING
|
|
49
|
+
has_rdoc: true
|
|
50
|
+
homepage: http://www.github.com/mvz/iba
|
|
51
|
+
licenses: []
|
|
52
|
+
|
|
53
|
+
post_install_message:
|
|
54
|
+
rdoc_options:
|
|
55
|
+
- --main
|
|
56
|
+
- README.rdoc
|
|
57
|
+
require_paths:
|
|
58
|
+
- lib
|
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
|
+
none: false
|
|
61
|
+
requirements:
|
|
62
|
+
- - ">="
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
hash: 3
|
|
65
|
+
segments:
|
|
66
|
+
- 0
|
|
67
|
+
version: "0"
|
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
|
+
none: false
|
|
70
|
+
requirements:
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
hash: 3
|
|
74
|
+
segments:
|
|
75
|
+
- 0
|
|
76
|
+
version: "0"
|
|
77
|
+
requirements: []
|
|
78
|
+
|
|
79
|
+
rubyforge_project:
|
|
80
|
+
rubygems_version: 1.3.7
|
|
81
|
+
signing_key:
|
|
82
|
+
specification_version: 3
|
|
83
|
+
summary: Introspective Block Assertions
|
|
84
|
+
test_files:
|
|
85
|
+
- test/analyse_test.rb
|
|
86
|
+
- test/assert_test.rb
|
|
87
|
+
- test/call_test.rb
|
|
88
|
+
- test/display_test.rb
|
|
89
|
+
- test/test_helper.rb
|