live_ast 0.7.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.rdoc CHANGED
@@ -1,6 +1,11 @@
1
1
 
2
2
  = live_ast Changes
3
3
 
4
+ == Version 1.0.0
5
+
6
+ * no known bugs; API is settled
7
+ * ast_load respects $VERBOSE=true
8
+
4
9
  == Version 0.7.3
5
10
 
6
11
  * live_ast/full now available for jruby (via boc gem)
@@ -1,4 +1,4 @@
1
1
 
2
2
  if RUBY_ENGINE == "jruby"
3
- Levitate.ruby_opts = %w[--1.9 -J-Djruby.astInspector.enabled=false]
3
+ Levitate.ruby_opts = %w[--1.9]
4
4
  end
@@ -35,7 +35,7 @@ module LiveAST
35
35
  begin
36
36
  yield
37
37
  ensure
38
- $VERBOSE = previous
38
+ $VERBOSE ||= previous
39
39
  end
40
40
  end
41
41
 
@@ -1,3 +1,3 @@
1
1
  module LiveAST
2
- VERSION = "0.7.3"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -8,7 +8,7 @@ class AAA_LoadPathTest < BaseTest
8
8
  begin
9
9
  check_load
10
10
  check_errors
11
- temp_file "foo.rb" do
11
+ temp_file nil, "foo.rb" do
12
12
  Dir.chdir(DATA_DIR) do
13
13
  compare_load_errors("/foo.rb")
14
14
  end
@@ -39,9 +39,7 @@ class AAA_LoadPathTest < BaseTest
39
39
  end
40
40
  }
41
41
 
42
- temp_file "foo.rb" do |path|
43
- write_file(path, code_1)
44
-
42
+ temp_file code_1, "foo.rb" do |path|
45
43
  Object.send(:remove_method, :hello) rescue nil
46
44
  load "foo.rb"
47
45
  assert_equal "password", hello
@@ -65,8 +63,7 @@ class AAA_LoadPathTest < BaseTest
65
63
  end
66
64
 
67
65
  def check_errors
68
- temp_file "foo.rb" do |path|
69
- touch path, :verbose => false
66
+ temp_file "# do nothing", "foo.rb" do |path|
70
67
  [
71
68
  "foo",
72
69
  "",
data/test/load_test.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require_relative 'main'
2
+ require_relative '../devel/levitate'
2
3
 
3
4
  class AAA_LoadFileTest < BaseTest
4
5
  class << self
@@ -13,9 +14,7 @@ class AAA_LoadFileTest < BaseTest
13
14
  y = 99
14
15
  }
15
16
 
16
- temp_file do |file|
17
- write_file file, code
18
-
17
+ temp_file code do |file|
19
18
  ret = LiveAST.load file
20
19
  assert_equal true, ret
21
20
  assert_equal :code_a, AAA_LoadFileTest.flag
@@ -34,11 +33,9 @@ class AAA_LoadFileTest < BaseTest
34
33
  r = 55
35
34
  }
36
35
 
37
- temp_file do |file|
36
+ temp_file code do |file|
38
37
  eval("r = 66", TOPLEVEL_BINDING)
39
38
 
40
- write_file file, code
41
-
42
39
  ret = LiveAST.load file
43
40
  assert_equal true, ret
44
41
  assert_equal :code_b, AAA_LoadFileTest.flag
@@ -54,9 +51,7 @@ class AAA_LoadFileTest < BaseTest
54
51
  ZOOM = 111
55
52
  }
56
53
 
57
- temp_file do |file|
58
- write_file file, code
59
-
54
+ temp_file code do |file|
60
55
  ret = LiveAST.load file, true
61
56
  assert_equal true, ret
62
57
  assert_equal :code_c, AAA_LoadFileTest.flag
@@ -76,10 +71,53 @@ class AAA_LoadFileTest < BaseTest
76
71
  AAA_LoadFileTest.from_d
77
72
  }
78
73
 
79
- temp_file do |file|
80
- write_file file, code
74
+ temp_file code do |file|
81
75
  LiveAST.load file
82
76
  assert_equal :code_d, AAA_LoadFileTest.flag
83
77
  end
84
78
  end
79
+
80
+ def test_verbose_respected
81
+ lib = File.expand_path(File.dirname(__FILE__) + "/../lib")
82
+
83
+ [
84
+ # respects a loaded file setting $VERBOSE = true
85
+ [
86
+ "false",
87
+ "true",
88
+ lambda { |file|
89
+ Levitate.run file
90
+ }
91
+ ],
92
+
93
+ # unfixable: does not respect a loaded file setting $VERBOSE = nil
94
+ [
95
+ "true",
96
+ "false",
97
+ lambda { |file|
98
+ unfixable do
99
+ assert_nothing_raised do
100
+ Levitate.run file
101
+ end
102
+ end
103
+ }
104
+ ]
105
+ ].each do |main_value, loaded_value, action|
106
+ loaded_code = %{
107
+ $VERBOSE = #{loaded_value}
108
+ }
109
+
110
+ temp_file loaded_code do |loaded_file|
111
+ main_code = %{
112
+ $LOAD_PATH.unshift '#{lib}'
113
+ require 'live_ast/base'
114
+ toplevel_local = 444
115
+ $VERBOSE = #{main_value}
116
+ LiveAST.load '#{loaded_file}'
117
+ $VERBOSE == #{loaded_value} or exit(1)
118
+ }
119
+ temp_file main_code, &action
120
+ end
121
+ end
122
+ end
85
123
  end
data/test/main.rb CHANGED
@@ -9,6 +9,8 @@ require 'minitest/unit'
9
9
  require 'minitest/mock'
10
10
  require 'minitest/autorun' unless defined? Rake
11
11
 
12
+ $VERBOSE = true
13
+
12
14
  require 'live_ast/base'
13
15
 
14
16
  def define_unsorted_test_case(name, superclass, &block)
@@ -72,12 +74,12 @@ class BaseTest < JLMiniTest
72
74
  RUBY_ENGINE != "jruby"
73
75
  end
74
76
 
75
- def temp_file(basename = nil)
77
+ def temp_file(code, basename = nil)
76
78
  basename ||= ('a'..'z').to_a.shuffle.join + ".rb"
77
79
  path = DATA_DIR + "/" + basename
78
80
  FileUtils.mkdir DATA_DIR unless File.directory? DATA_DIR
79
81
 
80
- FileUtils.rm_f path
82
+ write_file path, code if code
81
83
  begin
82
84
  yield path
83
85
  ensure
data/test/reload_test.rb CHANGED
@@ -28,8 +28,7 @@ class AAB_ReloadTest < BaseTest
28
28
  end
29
29
  }
30
30
 
31
- temp_file do |file|
32
- write_file file, code_1
31
+ temp_file code_1 do |file|
33
32
  load file
34
33
 
35
34
  LiveAST.ast(A.instance_method(:f))
@@ -61,8 +60,7 @@ class AAB_ReloadTest < BaseTest
61
60
  end
62
61
  }
63
62
 
64
- temp_file do |file|
65
- write_file file, code_1
63
+ temp_file code_1 do |file|
66
64
  load file
67
65
 
68
66
  LiveAST.ast(B.instance_method(:f))
@@ -92,8 +90,7 @@ class AAB_ReloadTest < BaseTest
92
90
  end
93
91
  }
94
92
 
95
- temp_file do |file|
96
- write_file file, code_1
93
+ temp_file code_1 do |file|
97
94
  load file
98
95
 
99
96
  LiveAST.ast(C.instance_method(:f))
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: live_ast
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.7.3
5
+ version: 1.0.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - James M. Lawrence
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-21 00:00:00 -04:00
13
+ date: 2011-03-23 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency