endlessruby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ ROOT = File.dirname(File.dirname(File.expand_path(__FILE__)))
2
+
3
+ require "test/unit"
4
+ require "#{ROOT}/lib/EndlessRuby"
5
+ class TestEndlessRuby < Test::Unit::TestCase
6
+
7
+ include EndlessRuby
8
+
9
+ def setup
10
+ end
11
+
12
+ def er2rb_right_output? want_output, input
13
+ assert_equal want_output, ER2RB(input)
14
+ end
15
+
16
+ def test_ereval
17
+ assert_equal "hello", ereval(<<ER)
18
+ "hello"
19
+ ER
20
+ end
21
+
22
+ end
23
+
24
+ require "#{ROOT}/test/test_helpers"
25
+ require "#{ROOT}/test/test_simply"
26
+ require "#{ROOT}/test/test_require"
27
+ require "#{ROOT}/test/test_use_end_case"
28
+
@@ -0,0 +1,28 @@
1
+ ROOT = File.dirname(File.dirname(File.expand_path(__FILE__)))
2
+
3
+ require "test/unit"
4
+ require "#{ROOT}/lib/EndlessRuby"
5
+ class TestEndlessRuby < Test::Unit::TestCase
6
+
7
+ include EndlessRuby
8
+
9
+ def setup
10
+ end
11
+
12
+ def er2rb_right_output? want_output, input
13
+ assert_equal want_output, ER2RB(input)
14
+ end
15
+
16
+ def test_ereval
17
+ assert_equal "hello", ereval(<<ER)
18
+ "hello"
19
+ ER
20
+ end
21
+
22
+ end
23
+
24
+ require "#{ROOT}/test/test_helpers"
25
+ require "#{ROOT}/test/test_simply"
26
+ require "#{ROOT}/test/test_require"
27
+ require "#{ROOT}/test/test_use_end_case"
28
+
@@ -0,0 +1,53 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "concrete examples" do
4
+
5
+ spec = File.dirname(__FILE__)
6
+ examples = %w[
7
+ concrete_examples/case_1_simply_test_case
8
+ ]
9
+
10
+ examples.each do |_case|
11
+ begin
12
+ er = open File.join(spec, "#{_case}.er")
13
+ rb = open File.join(spec, "#{_case}.rb")
14
+ rb_s = ERSpecHelper.chomp rb.read
15
+ er_s = er.read
16
+ it "must can compile #{_case}.er to #{_case}.rb" do
17
+ ER2RB(er_s).should == rb_s
18
+ end
19
+ ensure
20
+ er.close
21
+ rb.close
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ describe "discover bugs from concrete examples" do
28
+
29
+ it "the bug reappear when that contains spaces for the next end from the last breaking indentation" do
30
+ ER2RB(<<DEFINE).should ==
31
+ class TestEndlessRuby < Test::Unit::TestCase
32
+
33
+ include EndlessRuby
34
+
35
+ def setup
36
+ end
37
+
38
+ end
39
+ DEFINE
40
+ <<DEFINE.chomp!
41
+ class TestEndlessRuby < Test::Unit::TestCase
42
+
43
+ include EndlessRuby
44
+
45
+ def setup
46
+ end
47
+
48
+ end
49
+ DEFINE
50
+
51
+ end
52
+
53
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ require "simply_spec"
4
+ require "comment_spec"
5
+ require "blank_line_spec"
6
+ require "here_document_spec"
7
+ require "require_spec"
8
+ require "build_self_spec"
9
+ require "concrete_examples_spec"
10
+ require "semicolon_spec"
@@ -0,0 +1,60 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "here document case" do
4
+
5
+ it "CASE 1" do
6
+ ER2RB(<<DEFINE).should ==
7
+ def method
8
+ src = <<SRC
9
+ hello world
10
+ SRC
11
+ DEFINE
12
+ <<DEFINE.chomp!
13
+ def method
14
+ src = <<SRC
15
+ hello world
16
+ SRC
17
+ end
18
+ DEFINE
19
+ end
20
+
21
+ it "CASE 2" do
22
+ ER2RB(<<DEFINE).should ==
23
+ def method
24
+ src = <<-SRC
25
+ hello world
26
+ SRC
27
+ def method2
28
+ pass
29
+ DEFINE
30
+ <<DEFINE.chomp!
31
+ def method
32
+ src = <<-SRC
33
+ hello world
34
+ SRC
35
+ end
36
+ def method2
37
+ pass
38
+ end
39
+ DEFINE
40
+ end
41
+
42
+ it "CASE 3" do
43
+ ER2RB(<<DEFINE).should ==
44
+ def method
45
+ src = <<SRC
46
+ hello world
47
+ SRC
48
+ SRC
49
+ DEFINE
50
+ <<DEFINE.chomp!
51
+ def method
52
+ src = <<SRC
53
+ hello world
54
+ SRC
55
+ SRC
56
+ end
57
+ DEFINE
58
+ end
59
+
60
+ end
@@ -0,0 +1,29 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "require" do
4
+
5
+ it "require the file" do
6
+ require 'test_data/file.er'
7
+ $test_data.should == "file"
8
+ TestData.test_data.should == "file"
9
+ end
10
+
11
+ it "require the 'er' omission file" do
12
+ require 'test_data/er_omission'
13
+ $test_data.should == "er omission"
14
+ TestData.test_data.should == "er omission"
15
+ end
16
+
17
+ it "require the ruby script 'rb' omission" do
18
+ require 'test_data/rb_omission'
19
+ $test_data.should == "rb omission"
20
+ TestData.test_data.should == "rb omission"
21
+ end
22
+
23
+ it "require the ruby script" do
24
+ require 'test_data/ruby_script.rb'
25
+ $test_data.should == "ruby script"
26
+ TestData.test_data.should == "ruby script"
27
+ end
28
+
29
+ end
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "split with semicolon lines is inner lines" do
4
+
5
+ it "example" do
6
+ ER2RB(<<DEFINE).should ==
7
+ def method; statements; end
8
+ DEFINE
9
+ <<DEFINE.chomp!
10
+ def method
11
+ statements
12
+ end
13
+ DEFINE
14
+
15
+ end
16
+
17
+ end