jruby_visualizer 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,49 @@
1
+ require 'jruby_visualizer/ir_scope_registry'
2
+ require 'jruby_visualizer_test_utils'
3
+
4
+ describe IRScopeRegistry do
5
+ include JRubyVisualizerTestUtils
6
+
7
+ before(:each) do
8
+ @ruby_code = "\nclass Foo\n\ndef bar; 42; end; end;\nFoo.new.bar"
9
+ ast_root = ast_for(@ruby_code)
10
+ @root_scope = ir_scope_for(ast_root)
11
+ @ir_reg = IRScopeRegistry.new(@root_scope)
12
+ end
13
+
14
+ it "should be empty after clearing" do
15
+ @ir_reg.clear
16
+ @ir_reg.scopes.should be_empty
17
+ end
18
+
19
+ it "should contain three scopes for #{@ruby_code}" do
20
+ @ir_reg.scopes.size.should be(3)
21
+ end
22
+
23
+ it "should format the file scope - to a symbol" do
24
+ file_scope_symbol = @root_scope.key
25
+ file_scope_symbol.should be_an_instance_of Symbol
26
+ file_scope_symbol.should == :'-[-:0]'
27
+ end
28
+
29
+ it "should contain the file scope - at line 0" do
30
+ @ir_reg.scopes.should include(:'-[-:0]')
31
+ end
32
+
33
+ it "should contain the Foo (class) scope at line 1" do
34
+ @ir_reg.scopes.should include(:'Foo[-:1]')
35
+ end
36
+
37
+ it "should contain the scope for the method bar at line 3" do
38
+ @ir_reg.scopes.should include(:'bar[-:3]')
39
+ end
40
+
41
+ it "should refill correctly after clearing" do
42
+ @ir_reg.clear
43
+ @ir_reg.fill_registry(@root_scope.lexical_scopes.get(0))
44
+ @ir_reg.scopes.size.should be(2)
45
+ @ir_reg.scopes.should include(:'Foo[-:1]')
46
+ end
47
+
48
+ end
49
+
@@ -0,0 +1,19 @@
1
+ module JRubyVisualizerTestUtils
2
+ def ast_for(ruby_code)
3
+ JRuby::parse(ruby_code)
4
+ end
5
+
6
+ def ir_scope_for(ast_root)
7
+ ir_manager = JRuby::runtime.ir_manager
8
+ ir_manager.dry_run = true
9
+
10
+ builder =
11
+ if JRuby::runtime.is1_9?
12
+ org.jruby.ir.IRBuilder19
13
+ else
14
+ org.jruby.ir.IRBuilder
15
+ end
16
+ builder = builder.new(ir_manager)
17
+ builder.build_root(ast_root)
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+
8
+ $: << File.join(File.dirname(__FILE__), '../lib')
9
+
10
+ RSpec.configure do |config|
11
+ config.treat_symbols_as_metadata_keys_with_true_values = true
12
+ config.run_all_when_everything_filtered = true
13
+ config.filter_run :focus
14
+
15
+ # Run specs in random order to surface order dependencies. If you find an
16
+ # order dependency and want to debug it, you can fix the order by providing
17
+ # the seed, which is printed after each run.
18
+ # --seed 1234
19
+ config.order = 'random'
20
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jruby_visualizer
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Maximilian Konzack
9
+ - Thomas E. Enebo
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-10-04 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: jrubyfx
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: diffy
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ description: A Gem for visualizing JRuby compiler artifacts
48
+ email:
49
+ - maximilian.konzack@gmail.com
50
+ - tom.enebo@gmail.com
51
+ executables:
52
+ - jruby_visualizer
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - lib/jruby_visualizer.rb
57
+ - lib/jruby_visualizer/about_page.rb
58
+ - lib/jruby_visualizer/ast_tree_view_builder.rb
59
+ - lib/jruby_visualizer/cfg_visualizer.rb
60
+ - lib/jruby_visualizer/compiler_data.rb
61
+ - lib/jruby_visualizer/control_flow_graph_view.rb
62
+ - lib/jruby_visualizer/core_ext/ir_scope.rb
63
+ - lib/jruby_visualizer/ir_pretty_printer.rb
64
+ - lib/jruby_visualizer/ir_scope_registry.rb
65
+ - lib/jruby_visualizer/ir_visualizer.rb
66
+ - lib/jruby_visualizer/jruby_visualizer.rb
67
+ - lib/jruby_visualizer/ui/about.fxml
68
+ - lib/jruby_visualizer/ui/cfg-view.fxml
69
+ - lib/jruby_visualizer/ui/img/jruby-icon-32.png
70
+ - lib/jruby_visualizer/ui/img/jruby-icon-64.png
71
+ - lib/jruby_visualizer/ui/img/jruby-logo.png
72
+ - lib/jruby_visualizer/ui/ir-view.fxml
73
+ - lib/jruby_visualizer/ui/jruby-visualizer.fxml
74
+ - lib/jruby_visualizer/version.rb
75
+ - lib/jruby_visualizer/visualizer_compiler_pass_listener.rb
76
+ - lib/jruby_visualizer/visualizer_main_app.rb
77
+ - spec/compiler_data_spec.rb
78
+ - spec/ir_scope_registry_spec.rb
79
+ - spec/jruby_visualizer_test_utils.rb
80
+ - spec/spec_helper.rb
81
+ - bin/jruby_visualizer
82
+ homepage: http://github.com/jruby/jruby-visualizer
83
+ licenses: []
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project: jruby_visualizer
102
+ rubygems_version: 1.8.23
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: A Gem for visualizing JRuby compiler artifacts
106
+ test_files:
107
+ - spec/compiler_data_spec.rb
108
+ - spec/ir_scope_registry_spec.rb
109
+ - spec/jruby_visualizer_test_utils.rb
110
+ - spec/spec_helper.rb