picard 0.1 → 0.2.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/Gemfile +2 -2
- data/lib/picard.rb +1 -12
- data/lib/picard/assertion_wrapper.rb +74 -22
- data/lib/picard/ast_helper.rb +49 -45
- data/lib/picard/extensions.rb +7 -1
- data/lib/picard/method_ripper.rb +9 -9
- data/lib/picard/preprocessor.rb +0 -2
- data/lib/picard/version.rb +3 -4
- data/lib/picard_02.rb +11 -0
- data/picard.gemspec +3 -2
- data/test/picard/assertion_wrapper_test.rb +39 -6
- data/test/picard/ast_helper_test.rb +56 -46
- data/test/picard/class_ripper_test.rb +1 -1
- data/test/picard/demo_test.rb +30 -4
- data/test/picard/error_message_formatter_test.rb +1 -1
- data/test/picard/method_ripper_test.rb +1 -1
- data/test/picard/preprocessor_test.rb +1 -1
- data/test/picard/test_unit_test.rb +1 -1
- data/test/test_helper.rb +4 -10
- metadata +27 -15
data/Gemfile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
-
|
3
|
-
gemspec
|
2
|
+
gem 'rake'
|
3
|
+
gemspec
|
data/lib/picard.rb
CHANGED
@@ -1,12 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require_relative 'picard/extensions'
|
4
|
-
require_relative 'picard/context'
|
5
|
-
require_relative 'picard/error_message_formatter'
|
6
|
-
require_relative 'picard/ast_helper'
|
7
|
-
require_relative 'picard/assertion_wrapper'
|
8
|
-
require_relative 'picard/s_expression_sugar'
|
9
|
-
require_relative 'picard/class_ripper'
|
10
|
-
require_relative 'picard/preprocessor'
|
11
|
-
require_relative 'picard/method_ripper'
|
12
|
-
require_relative 'picard/test_unit'
|
1
|
+
require_relative 'picard_02'
|
@@ -1,43 +1,95 @@
|
|
1
|
-
require 'live_ast'
|
2
1
|
require 'ruby2ruby'
|
3
2
|
require_relative 's_expression_sugar'
|
4
3
|
|
5
4
|
module Picard
|
5
|
+
|
6
|
+
class BasicAssertion
|
7
|
+
def extract_argument ast
|
8
|
+
ast[3][1]
|
9
|
+
end
|
10
|
+
|
11
|
+
def extract_receiver ast
|
12
|
+
ast[1]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Default < BasicAssertion
|
17
|
+
def === ast
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def transform ast, message
|
22
|
+
s(:call, nil, :assert, s(:arglist,ast, s(:str, message)))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class EqualTo < BasicAssertion
|
27
|
+
def === ast
|
28
|
+
ast[0] == :call and ast[2] == :==
|
29
|
+
end
|
30
|
+
|
31
|
+
def transform ast, message
|
32
|
+
s(:call, nil,
|
33
|
+
:assert_equal,
|
34
|
+
s(:arglist,
|
35
|
+
extract_argument(ast),
|
36
|
+
extract_receiver(ast),
|
37
|
+
s(:str, message)))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class NotEqualTo < BasicAssertion
|
42
|
+
def === ast
|
43
|
+
ast[0] == :call and ast[2] == :'!='
|
44
|
+
end
|
45
|
+
|
46
|
+
def transform ast, message
|
47
|
+
s(:call, nil,
|
48
|
+
:assert_not_equal,
|
49
|
+
s(:arglist,
|
50
|
+
extract_argument(ast),
|
51
|
+
extract_receiver(ast),
|
52
|
+
s(:str, message)))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class Match < BasicAssertion
|
57
|
+
def === ast
|
58
|
+
ast[0] == :call and ast[2] == :'=~'
|
59
|
+
end
|
60
|
+
|
61
|
+
def transform ast, message
|
62
|
+
s(:call, nil,
|
63
|
+
:assert_match,
|
64
|
+
s(:arglist,
|
65
|
+
extract_argument(ast),
|
66
|
+
extract_receiver(ast),
|
67
|
+
s(:str, message)))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
6
71
|
class AssertionWrapper
|
7
72
|
include Picard::SExpressionSugar
|
8
73
|
|
9
74
|
def initialize formatter = ErrorMessageFormatter.new
|
10
75
|
@formatter = formatter
|
76
|
+
@handlers = [EqualTo.new, NotEqualTo.new, Match.new, Default.new]
|
11
77
|
end
|
12
78
|
|
13
79
|
def wrap_assertion ast, context
|
14
80
|
line = ast_to_str(ast)
|
15
81
|
message = @formatter.format_message(line, context)
|
16
|
-
|
17
|
-
if equal_to_assertion? ast
|
18
|
-
s(:call, nil,
|
19
|
-
:assert_equal,
|
20
|
-
s(:arglist,
|
21
|
-
extract_argument(ast),
|
22
|
-
extract_receiver(ast),
|
23
|
-
s(:str, message)))
|
24
|
-
else
|
25
|
-
s(:call, nil, :assert, s(:arglist,ast, s(:str, message)))
|
26
|
-
end
|
27
|
-
end
|
28
82
|
|
29
|
-
|
30
|
-
|
31
|
-
def equal_to_assertion? ast
|
32
|
-
ast[0] == :call and ast[2] == :==
|
83
|
+
handler = find_matching_handler ast
|
84
|
+
handler.transform ast, message
|
33
85
|
end
|
34
86
|
|
35
|
-
|
36
|
-
ast[3][1]
|
37
|
-
end
|
87
|
+
private
|
38
88
|
|
39
|
-
def
|
40
|
-
|
89
|
+
def find_matching_handler ast
|
90
|
+
@handlers.find do |h|
|
91
|
+
h === ast
|
92
|
+
end
|
41
93
|
end
|
42
94
|
|
43
95
|
def ast_to_str ast
|
data/lib/picard/ast_helper.rb
CHANGED
@@ -1,80 +1,84 @@
|
|
1
|
-
require 'live_ast'
|
2
1
|
require 'ruby2ruby'
|
3
2
|
|
4
3
|
module Picard
|
5
|
-
class AstHelper
|
6
|
-
ResultItem = Struct.new(:index, :ast)
|
7
4
|
|
8
|
-
|
9
|
-
@wrapper = wrapper
|
10
|
-
end
|
5
|
+
ResultItem = Struct.new(:ast, :index)
|
11
6
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
wrap_in_result_items body_statements
|
7
|
+
class AstHelper
|
8
|
+
def initialize(wrapper = Picard::AssertionWrapper.new)
|
9
|
+
@wrapper = wrapper
|
16
10
|
end
|
17
11
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
def extract_ast method
|
13
|
+
ast = method.to_sexp do |code|
|
14
|
+
index = code.index('def') + 3
|
15
|
+
code[index...index] = ' fake.'
|
16
|
+
true
|
17
|
+
end
|
18
|
+
MethodAst.new ast
|
23
19
|
end
|
24
20
|
|
25
21
|
def wrap_assertion method, ast
|
26
22
|
context = Picard::Context.new(method.source_location[0], ast.line)
|
27
23
|
@wrapper.wrap_assertion ast, context
|
28
24
|
end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
end
|
26
|
+
|
27
|
+
class MethodAst
|
28
|
+
def initialize ast
|
29
|
+
@ast = ast
|
34
30
|
end
|
35
31
|
|
36
|
-
def
|
37
|
-
|
38
|
-
|
39
|
-
remove_spaces str
|
32
|
+
def body_statements
|
33
|
+
st = wrap_into_result_items(all_statements)
|
34
|
+
remove_prefix_statement st
|
40
35
|
end
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
37
|
+
def all_statements_in_block block_name
|
38
|
+
statements = body_statements
|
39
|
+
start_index = find_index_of_statements_calling(statements, block_name)
|
40
|
+
start_index ? statements[start_index + 1 .. -1] : []
|
46
41
|
end
|
47
42
|
|
48
|
-
def
|
49
|
-
|
43
|
+
def replace_statement! index, new_statement
|
44
|
+
all_statements[index] = new_statement
|
50
45
|
end
|
51
46
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
55
|
-
ast[0] == :call and ast[2] == method_name
|
56
|
-
end
|
47
|
+
def generate_method
|
48
|
+
str = ast_to_str(@ast)
|
49
|
+
remove_spaces str
|
57
50
|
end
|
58
51
|
|
59
|
-
|
60
|
-
|
61
|
-
|
52
|
+
private
|
53
|
+
|
54
|
+
def wrap_into_result_items statements
|
55
|
+
res = []
|
56
|
+
statements.each_with_index do |s, i|
|
57
|
+
res << ResultItem.new(s, i)
|
58
|
+
end
|
59
|
+
res
|
62
60
|
end
|
63
61
|
|
64
62
|
def remove_prefix_statement statements
|
65
63
|
statements[1..-1]
|
66
64
|
end
|
67
65
|
|
68
|
-
def
|
69
|
-
|
66
|
+
def all_statements
|
67
|
+
@ast[3][1]
|
70
68
|
end
|
71
69
|
|
72
|
-
def
|
73
|
-
|
74
|
-
|
75
|
-
res << ResultItem.new(i, e)
|
70
|
+
def find_index_of_statements_calling items, method_name
|
71
|
+
items.index do |item|
|
72
|
+
item.ast[0] == :call and item.ast[2] == method_name
|
76
73
|
end
|
77
|
-
|
74
|
+
end
|
75
|
+
|
76
|
+
def ast_to_str ast
|
77
|
+
Ruby2Ruby.new.process ast
|
78
|
+
end
|
79
|
+
|
80
|
+
def remove_spaces str
|
81
|
+
str.gsub(/\n\s+/, "\n")
|
78
82
|
end
|
79
83
|
end
|
80
84
|
end
|
data/lib/picard/extensions.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'sourcify'
|
2
|
+
|
1
3
|
module Picard
|
2
4
|
class ::Object
|
3
5
|
def metaclass; class << self; self; end; end
|
@@ -7,4 +9,8 @@ module Picard
|
|
7
9
|
meta_eval { define_method name, &blk }
|
8
10
|
end
|
9
11
|
end
|
10
|
-
|
12
|
+
|
13
|
+
::UnboundMethod.class_eval do
|
14
|
+
include Sourcify::Method
|
15
|
+
end
|
16
|
+
end
|
data/lib/picard/method_ripper.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'live_ast'
|
2
|
-
|
3
1
|
module Picard
|
4
2
|
class MethodRipper
|
5
3
|
def initialize ast_helper = AstHelper.new
|
@@ -7,22 +5,24 @@ module Picard
|
|
7
5
|
end
|
8
6
|
|
9
7
|
def wrap_all_assertions! method
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
ast = @ast_helper.extract_ast(method)
|
9
|
+
assertions = ast.all_statements_in_block(:expect)
|
10
|
+
|
11
|
+
replace_all_statements_with_assertions! ast, assertions, method
|
12
|
+
replace_method_implementation_in_owner! ast, method
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
def replace_all_statements_with_assertions! assertions, method
|
17
|
+
def replace_all_statements_with_assertions! ast, assertions, method
|
18
18
|
assertions.each do |e|
|
19
19
|
wrapped = @ast_helper.wrap_assertion(method, e.ast)
|
20
|
-
|
20
|
+
ast.replace_statement!(e.index, wrapped)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def replace_method_implementation_in_owner! method
|
25
|
-
new_method_str =
|
24
|
+
def replace_method_implementation_in_owner! ast, method
|
25
|
+
new_method_str = ast.generate_method
|
26
26
|
method.owner.class_eval new_method_str
|
27
27
|
end
|
28
28
|
end
|
data/lib/picard/preprocessor.rb
CHANGED
data/lib/picard/version.rb
CHANGED
data/lib/picard_02.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require_relative "picard/version"
|
2
|
+
require_relative 'picard/extensions'
|
3
|
+
require_relative 'picard/context'
|
4
|
+
require_relative 'picard/error_message_formatter'
|
5
|
+
require_relative 'picard/ast_helper'
|
6
|
+
require_relative 'picard/assertion_wrapper'
|
7
|
+
require_relative 'picard/s_expression_sugar'
|
8
|
+
require_relative 'picard/class_ripper'
|
9
|
+
require_relative 'picard/preprocessor'
|
10
|
+
require_relative 'picard/method_ripper'
|
11
|
+
require_relative 'picard/test_unit'
|
data/picard.gemspec
CHANGED
@@ -18,7 +18,8 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_dependency '
|
22
|
-
s.add_dependency 'live_ast_ripper', '= 0.6.5'
|
21
|
+
s.add_dependency 'sourcify', '>= 0.6.0.rc1'
|
23
22
|
s.add_development_dependency 'flexmock'
|
23
|
+
s.add_development_dependency 'picard', '= 0.1'
|
24
|
+
s.add_development_dependency 'test-unit'
|
24
25
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
class Picard::AssertionWrapperTest < Test::Unit::TestCase
|
4
|
-
include
|
5
|
-
include
|
4
|
+
include PicardStable::TestUnit
|
5
|
+
include PicardStable::SExpressionSugar
|
6
6
|
|
7
7
|
def setup
|
8
8
|
@formatter = flexmock('formatter')
|
@@ -12,8 +12,7 @@ class Picard::AssertionWrapperTest < Test::Unit::TestCase
|
|
12
12
|
def test_should_wrap_simple_assertions
|
13
13
|
given
|
14
14
|
ast = s(:lit, true)
|
15
|
-
context =
|
16
|
-
@formatter.should_receive(:format_message).with('true', context).and_return('generated error message')
|
15
|
+
context = init_context_and_formatter('true')
|
17
16
|
|
18
17
|
expect
|
19
18
|
@wrapper.wrap_assertion(ast, context) == s(:call, nil,
|
@@ -26,8 +25,7 @@ class Picard::AssertionWrapperTest < Test::Unit::TestCase
|
|
26
25
|
def test_should_wrap_equal_to_assertions
|
27
26
|
given
|
28
27
|
ast = s(:call, s(:lit, 1), :==, s(:arglist, s(:lit, 2)))
|
29
|
-
context =
|
30
|
-
@formatter.should_receive(:format_message).with('(1 == 2)', context).and_return('generated error message')
|
28
|
+
context = init_context_and_formatter('(1 == 2)')
|
31
29
|
|
32
30
|
expect
|
33
31
|
@wrapper.wrap_assertion(ast, context) == s(:call, nil,
|
@@ -37,4 +35,39 @@ class Picard::AssertionWrapperTest < Test::Unit::TestCase
|
|
37
35
|
s(:lit, 1),
|
38
36
|
s(:str, 'generated error message')))
|
39
37
|
end
|
38
|
+
|
39
|
+
def test_should_wrap_not_equal_to_assertions
|
40
|
+
given
|
41
|
+
ast = s(:call, s(:lit, 1), :'!=', s(:arglist, s(:lit, 2)))
|
42
|
+
context = init_context_and_formatter('1.!=(2)')
|
43
|
+
|
44
|
+
expect
|
45
|
+
@wrapper.wrap_assertion(ast, context) == s(:call, nil,
|
46
|
+
:assert_not_equal,
|
47
|
+
s(:arglist,
|
48
|
+
s(:lit, 2),
|
49
|
+
s(:lit, 1),
|
50
|
+
s(:str, 'generated error message')))
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_should_wrap_matching_assertions
|
54
|
+
given
|
55
|
+
ast = s(:call, s(:lit, 1), :'=~', s(:arglist, s(:lit, 2)))
|
56
|
+
context = init_context_and_formatter('1.=~(2)')
|
57
|
+
|
58
|
+
expect
|
59
|
+
@wrapper.wrap_assertion(ast, context) == s(:call, nil,
|
60
|
+
:assert_match,
|
61
|
+
s(:arglist,
|
62
|
+
s(:lit, 2),
|
63
|
+
s(:lit, 1),
|
64
|
+
s(:str, 'generated error message')))
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
def init_context_and_formatter line
|
69
|
+
context = flexmock(:file => 'file', :lineno => 1)
|
70
|
+
@formatter.should_receive(:format_message).with(line, context).and_return('generated error message')
|
71
|
+
context
|
72
|
+
end
|
40
73
|
end
|
@@ -1,117 +1,127 @@
|
|
1
1
|
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
class Picard::AstHelperTest < Test::Unit::TestCase
|
4
|
-
include
|
5
|
-
include
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@wrapper = flexmock('wrapper')
|
9
|
-
@helper = Picard::AstHelper.new @wrapper
|
10
|
-
end
|
11
|
-
|
4
|
+
include PicardStable::TestUnit
|
5
|
+
include PicardStable::SExpressionSugar
|
12
6
|
|
13
7
|
class TestClass1
|
14
8
|
def test_method
|
15
|
-
one
|
16
|
-
two
|
17
9
|
end
|
18
10
|
end
|
19
11
|
|
20
|
-
def
|
12
|
+
def test_ast_helper_should_add_nil_to_empty_method
|
21
13
|
given
|
22
|
-
|
23
|
-
actual = @helper.all_statements(method)
|
14
|
+
ast = ast_of(TestClass1)
|
24
15
|
|
25
16
|
expect
|
26
|
-
|
27
|
-
actual[0].ast == s(:call, nil, :one, s(:arglist))
|
28
|
-
|
29
|
-
actual[1].index == 1
|
30
|
-
actual[1].ast == s(:call, nil, :two, s(:arglist))
|
17
|
+
ast.body_statements[0].ast == s(:nil)
|
31
18
|
end
|
32
19
|
|
33
20
|
|
34
21
|
class TestClass2
|
35
22
|
def test_method
|
36
23
|
one
|
37
|
-
expect
|
38
24
|
two
|
39
25
|
end
|
40
26
|
end
|
41
27
|
|
42
|
-
def
|
28
|
+
def test_ast_helper_should_extract_ast_including_body_statments
|
43
29
|
given
|
44
|
-
|
45
|
-
actual = @helper.all_statements_in_block(method, :expect)
|
30
|
+
statements = ast_of(TestClass2).body_statements
|
46
31
|
|
47
32
|
expect
|
48
|
-
|
49
|
-
|
50
|
-
|
33
|
+
statements[0].index == 1
|
34
|
+
statements[0].ast == s(:call, nil, :one, s(:arglist))
|
35
|
+
|
36
|
+
statements[1].index == 2
|
37
|
+
statements[1].ast == s(:call, nil, :two, s(:arglist))
|
51
38
|
end
|
52
39
|
|
53
40
|
|
54
41
|
class TestClass3
|
55
42
|
def test_method
|
56
43
|
one
|
44
|
+
expect
|
57
45
|
two
|
58
46
|
end
|
59
47
|
end
|
60
48
|
|
61
|
-
def
|
49
|
+
def test_method_ast_should_return_all_statements_in_block
|
62
50
|
given
|
63
|
-
|
51
|
+
statements = ast_of(TestClass3).all_statements_in_block(:expect)
|
64
52
|
|
65
53
|
expect
|
66
|
-
|
54
|
+
statements[0].index == 3
|
55
|
+
statements[0].ast = s(:call, nil, :two, s(:arglist))
|
67
56
|
end
|
68
57
|
|
69
58
|
|
70
59
|
class TestClass4
|
71
60
|
def test_method
|
72
|
-
|
61
|
+
one
|
62
|
+
two
|
73
63
|
end
|
74
64
|
end
|
75
65
|
|
76
|
-
def
|
66
|
+
def test_method_ast_should_return_empty_array_if_block_is_not_found
|
77
67
|
given
|
78
|
-
|
79
|
-
@helper.replace_statement(method, 0, s(:lit, true))
|
80
|
-
all_statements = @helper.all_statements(method)
|
68
|
+
statements = ast_of(TestClass4)
|
81
69
|
|
82
70
|
expect
|
83
|
-
|
71
|
+
statements.all_statements_in_block(:where) == []
|
84
72
|
end
|
85
73
|
|
86
74
|
|
87
75
|
class TestClass5
|
88
|
-
def
|
76
|
+
def test_method
|
77
|
+
false
|
89
78
|
end
|
90
79
|
end
|
91
80
|
|
92
|
-
def
|
81
|
+
def test_method_ast_should_replace_statement
|
93
82
|
given
|
94
|
-
|
95
|
-
ast
|
96
|
-
@wrapper.should_receive(:wrap_assertion).and_return('wrapped ast')
|
83
|
+
ast = ast_of(TestClass5)
|
84
|
+
ast.replace_statement!(1, s(:true))
|
97
85
|
|
98
86
|
expect
|
99
|
-
|
87
|
+
ast.body_statements[0].ast == s(:true)
|
100
88
|
end
|
101
89
|
|
102
90
|
|
103
|
-
class
|
104
|
-
def
|
91
|
+
class TestClass6
|
92
|
+
def test_method
|
105
93
|
false
|
106
94
|
end
|
107
95
|
end
|
108
96
|
|
109
|
-
def
|
97
|
+
def test_method_ast_should_generate_method_as_string
|
110
98
|
given
|
111
|
-
|
112
|
-
|
99
|
+
ast = ast_of(TestClass5)
|
100
|
+
|
101
|
+
expect
|
102
|
+
ast.generate_method == "def test_method\nfalse\nend"
|
103
|
+
end
|
104
|
+
|
113
105
|
|
106
|
+
def test_ast_helper_should_wrap_assertion
|
107
|
+
given
|
108
|
+
ast = flexmock(:line => 100)
|
109
|
+
method = flexmock(:source_location => ['location'])
|
110
|
+
expected_context = Picard::Context.new('location', 100)
|
111
|
+
|
112
|
+
wrapper = flexmock('wrapper')
|
113
|
+
wrapper.should_receive(:wrap_assertion).with(ast, expected_context).and_return('wrapped ast')
|
114
|
+
|
115
|
+
helper = Picard::AstHelper.new(wrapper)
|
116
|
+
|
114
117
|
expect
|
115
|
-
|
118
|
+
helper.wrap_assertion(method, ast) == 'wrapped ast'
|
119
|
+
end
|
120
|
+
|
121
|
+
private
|
122
|
+
|
123
|
+
def ast_of(clazz)
|
124
|
+
method = clazz.instance_method(:test_method)
|
125
|
+
Picard::AstHelper.new.extract_ast(method)
|
116
126
|
end
|
117
127
|
end
|
data/test/picard/demo_test.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
require File.expand_path("../../test_helper", __FILE__)
|
2
|
-
require 'live_ast'
|
2
|
+
#require 'live_ast'
|
3
|
+
#require 'live_ast_ripper'
|
4
|
+
#require 'sorcerer'
|
5
|
+
#require 'test/unit'
|
6
|
+
#require 'sourcify'
|
7
|
+
#require 'ruby2ruby'
|
8
|
+
|
3
9
|
|
4
10
|
module Picard
|
5
11
|
class DemoTest < Test::Unit::TestCase
|
@@ -7,11 +13,31 @@ module Picard
|
|
7
13
|
#
|
8
14
|
#def test_one
|
9
15
|
# expect
|
10
|
-
#
|
16
|
+
# 2 == 2
|
17
|
+
#end
|
18
|
+
|
19
|
+
#def method1
|
20
|
+
# false
|
11
21
|
#end
|
12
|
-
|
13
|
-
#
|
22
|
+
|
23
|
+
#def test_what_breaks_ruby
|
24
|
+
# #method = MyMath.method(:regular_method)
|
25
|
+
# #puts method.inspect
|
26
|
+
# #puts method.to_sexp.inspect
|
27
|
+
# method = DemoTest.instance_method(:method1)
|
28
|
+
# #method = method.bind('fake')
|
29
|
+
# puts method.inspect
|
30
|
+
#
|
31
|
+
# ast = method.to_sexp do |code|
|
32
|
+
# index = code.index('def') + 3
|
33
|
+
# code[index...index] = ' fake.'
|
34
|
+
# true
|
35
|
+
# end
|
36
|
+
# puts ast.inspect
|
37
|
+
# puts Ruby2Ruby.new.process(ast)
|
38
|
+
# #puts(ast.inspect)
|
14
39
|
#end
|
40
|
+
|
15
41
|
#
|
16
42
|
#def test_two
|
17
43
|
# ast = DemoTest.instance_method(:regular_method).to_ast
|
data/test/test_helper.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'flexmock/test_unit'
|
3
|
+
require 'picard'
|
4
|
+
PicardStable = PicardTestFramework::V01
|
3
5
|
|
4
|
-
|
5
|
-
require_relative '../lib/
|
6
|
-
require_relative '../lib/picard/error_message_formatter'
|
7
|
-
require_relative '../lib/picard/ast_helper'
|
8
|
-
require_relative '../lib/picard/assertion_wrapper'
|
9
|
-
require_relative '../lib/picard/s_expression_sugar'
|
10
|
-
require_relative '../lib/picard/class_ripper'
|
11
|
-
require_relative '../lib/picard/preprocessor'
|
12
|
-
require_relative '../lib/picard/method_ripper'
|
13
|
-
require_relative '../lib/picard/test_unit'
|
6
|
+
Picard = PicardTestFramework::V02
|
7
|
+
require_relative '../lib/picard_02.rb'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,33 +9,44 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-22 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement: &
|
15
|
+
name: sourcify
|
16
|
+
requirement: &2153158180 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.6.0.rc1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153158180
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: flexmock
|
27
|
+
requirement: &2153157260 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2153157260
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement: &
|
37
|
+
name: picard
|
38
|
+
requirement: &2153155940 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - =
|
31
42
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
33
|
-
type: :
|
43
|
+
version: '0.1'
|
44
|
+
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153155940
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
48
|
+
name: test-unit
|
49
|
+
requirement: &2153154960 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ! '>='
|
@@ -43,7 +54,7 @@ dependencies:
|
|
43
54
|
version: '0'
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *2153154960
|
47
58
|
description: Test framework inspired by Spock
|
48
59
|
email:
|
49
60
|
- vic.savkin@gmail.com
|
@@ -68,6 +79,7 @@ files:
|
|
68
79
|
- lib/picard/s_expression_sugar.rb
|
69
80
|
- lib/picard/test_unit.rb
|
70
81
|
- lib/picard/version.rb
|
82
|
+
- lib/picard_02.rb
|
71
83
|
- picard.gemspec
|
72
84
|
- test/picard/assertion_wrapper_test.rb
|
73
85
|
- test/picard/ast_helper_test.rb
|