rubyjs 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,146 @@
1
+ #
2
+ # Examples taken from: http://hotruby.accelart.jp/
3
+ #
4
+ class TestHotRuby
5
+ def sort ary
6
+ puts "Before insertion sort:"
7
+ p ary
8
+
9
+ for i in 1..(ary.length-1) do
10
+ n = i
11
+ while n >= 1 && ary[n] < ary[n - 1] do
12
+ if ary[n] < ary[n - 1]
13
+ tmp = ary[n]
14
+ ary[n] = ary[n - 1]
15
+ ary[n - 1] = tmp
16
+ end
17
+ n -= 1
18
+ end
19
+ end
20
+
21
+ puts "After insertion sort:"
22
+ p ary
23
+ end
24
+
25
+ def addPrint a, b, c
26
+ puts a + b + c
27
+ end
28
+
29
+ def self.main
30
+ t = new()
31
+
32
+ puts "InsertionSort"
33
+ t.sort [3, 6, 2, 5, 3, 7, 1, 8]
34
+
35
+ puts "Array args"
36
+ ary = [' World ', '!']
37
+ t.addPrint 'Hello', *ary
38
+
39
+ puts "Block"
40
+ Foo.new.main
41
+
42
+ puts "Class"
43
+ puts Pi::PI
44
+ # different precision on Ruby vs. Javascript
45
+ puts Pi.new.calc.to_s[0,13]
46
+
47
+
48
+ puts "Const"
49
+ # FIXME
50
+ =begin
51
+ Bar_::Baz_.new.run
52
+ Bar2.new.run
53
+ Object::Bar2.new.run
54
+ Bar3.new.run
55
+ =end
56
+ end
57
+ end
58
+
59
+ #
60
+ # Block
61
+ #
62
+ class Hoge
63
+ def add_msg &block
64
+ block.call "is" # s/yield/call/
65
+ end
66
+ end
67
+
68
+ class Foo
69
+ NAME = ' - William Shakespeare'
70
+ def main
71
+ pre = "Action"
72
+ @space = " "
73
+ Hoge.new.add_msg do |msg|
74
+ fuga = "eloquence"
75
+ puts pre + @space + msg + @space + fuga + NAME
76
+ end
77
+ end
78
+ end
79
+
80
+ #
81
+ # Class
82
+ #
83
+ class Pi
84
+ def initialize
85
+ @a = 355.0
86
+ end
87
+
88
+ def calc
89
+ b = 113.0
90
+ return @a / b
91
+ end
92
+
93
+ PI = 'PI is about'
94
+ end
95
+
96
+ #
97
+ # Const
98
+ #
99
+ class Foo_
100
+ CONST = 'Foo'
101
+ end
102
+
103
+ class Bar_
104
+ CONST = 'Bar'
105
+
106
+ class Baz_ < Foo_
107
+ def run
108
+ puts CONST # => "Bar" Outer class const
109
+ # In this case, you have to specify if you want to see parent class const.
110
+ puts Foo_::CONST # => "Foo"
111
+ end
112
+ end
113
+ end
114
+
115
+ class Foo2
116
+ CONST = 'Foo'
117
+ end
118
+
119
+ CONST = 'Object'
120
+
121
+ class Bar2 < Foo2
122
+ def run
123
+ puts CONST # => "Foo"
124
+ end
125
+ end
126
+
127
+ # If you specify "Object", then const in Object is searched before.
128
+ class Object
129
+ class Bar2 < Foo2
130
+ def run
131
+ puts CONST # => "Object"
132
+ end
133
+ end
134
+ end
135
+
136
+ class Foo3
137
+ CONST = 'Foo'
138
+ end
139
+ class Bar3 < Foo3
140
+ def run
141
+ puts CONST # => "Foo"
142
+ #CONST = 'Bar' # Define Bar's const "CONST"
143
+ puts CONST # => "Bar" (Foo::CONST is hidden)
144
+ puts Foo3::CONST # => "Foo" (You can see by "::")
145
+ end
146
+ end
@@ -0,0 +1,25 @@
1
+ class TestInsertionSort
2
+ def sort ary
3
+ puts "Before insertion sort:"
4
+ p ary
5
+
6
+ for i in 1..(ary.length-1) do
7
+ n = i
8
+ while n >= 1 && ary[n] < ary[n - 1] do
9
+ if ary[n] < ary[n - 1]
10
+ tmp = ary[n]
11
+ ary[n] = ary[n - 1]
12
+ ary[n - 1] = tmp
13
+ end
14
+ n -= 1
15
+ end
16
+ end
17
+
18
+ puts "After insertion sort:"
19
+ p ary
20
+ end
21
+
22
+ def self.main
23
+ new.sort [3, 6, 2, 5, 3, 7, 1, 8]
24
+ end
25
+ end
data/test/test_range.rb CHANGED
@@ -5,6 +5,10 @@ class TestRange
5
5
  p a.last
6
6
  p a
7
7
 
8
+ i = 1
9
+ p ((i..i+5).to_s)
10
+ p ((i...i+i).to_s)
11
+
8
12
  p ((0..2).to_s)
9
13
  p ((0...2).to_s)
10
14
 
@@ -45,6 +49,19 @@ class TestRange
45
49
  p ((0..2) == (0..2))
46
50
  p ((0..2) == Range.new(0,2))
47
51
  p ((0..2) == (0...2))
52
+
53
+ j = 55
54
+ p j
55
+ for i in 1..100
56
+ j = i
57
+ end
58
+ p j
59
+
60
+ j = 54
61
+ p j
62
+ for j in 1..100
63
+ end
64
+ p j
48
65
  end
49
66
 
50
67
  def self.main
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Neumann
@@ -30,176 +30,178 @@ extensions: []
30
30
  extra_rdoc_files: []
31
31
 
32
32
  files:
33
- - bin
34
- - bin/rubyjs
33
+ - Rakefile
34
+ - examples
35
+ - examples/hw
36
+ - examples/hw/hw.js
37
+ - examples/hw/index.html
38
+ - examples/hw/hw.rb
39
+ - examples/hw/Rakefile
40
+ - examples/ex1
41
+ - examples/ex1/ex1.rb
42
+ - examples/ex1/Rakefile
43
+ - examples/ex1/ex1.js
44
+ - examples/ex1/index.html
35
45
  - src
36
- - src/rubyjs
37
- - src/rubyjs/name_generator.rb
38
- - src/rubyjs/encoder.rb
39
- - src/rubyjs/eval_into.rb
40
- - src/rubyjs/compiler.rb
41
- - src/rubyjs/lib
42
- - src/rubyjs/lib/core.rb
43
- - src/rubyjs/lib/json.rb
44
- - src/rubyjs/debug_name_generator.rb
45
- - src/rubyjs/code_generator.rb
46
- - src/rubyjs/model.rb
47
46
  - src/rubyjs.rb
48
47
  - src/rwt
48
+ - src/rwt/DOM.Opera.rb
49
49
  - src/rwt/Label.rb
50
50
  - src/rwt/Widget.rb
51
+ - src/rwt/HTTPRequest.IE6.rb
52
+ - src/rwt/DOM.Konqueror.rb
51
53
  - src/rwt/UIObject.rb
52
- - src/rwt/HTTPRequest.rb
53
54
  - src/rwt/AbsolutePanel.rb
54
- - src/rwt/DOM.Konqueror.rb
55
55
  - src/rwt/Panel.rb
56
- - src/rwt/Event.Opera.rb
57
- - src/rwt/HTTPRequest.IE6.rb
58
- - src/rwt/DOM.Opera.rb
59
- - src/rwt/RootPanel.rb
60
- - src/rwt/Event.rb
56
+ - src/rwt/DOM.rb
61
57
  - src/rwt/ported-from
62
58
  - src/rwt/ported-from/DOMImplStandard.java
63
- - src/rwt/ported-from/Panel.java
64
59
  - src/rwt/ported-from/Label.java
60
+ - src/rwt/ported-from/UIObject.java
65
61
  - src/rwt/ported-from/DOMImpl.java
66
62
  - src/rwt/ported-from/HTTPRequest.java
67
- - src/rwt/ported-from/UIObject.java
63
+ - src/rwt/ported-from/Panel.java
64
+ - src/rwt/ported-from/Widget.java
65
+ - src/rwt/ported-from/AbsolutePanel.java
68
66
  - src/rwt/ported-from/HTTPRequestImpl.java
69
67
  - src/rwt/ported-from/DOMImplOpera.java
70
68
  - src/rwt/ported-from/DOM.java
71
- - src/rwt/ported-from/Widget.java
72
- - src/rwt/ported-from/AbsolutePanel.java
73
- - src/rwt/DOM.rb
69
+ - src/rwt/Event.rb
70
+ - src/rwt/HTTPRequest.rb
71
+ - src/rwt/Event.Opera.rb
72
+ - src/rwt/RootPanel.rb
73
+ - src/rubyjs
74
+ - src/rubyjs/encoder.rb
75
+ - src/rubyjs/model.rb
76
+ - src/rubyjs/code_generator.rb
77
+ - src/rubyjs/debug_name_generator.rb
78
+ - src/rubyjs/eval_into.rb
79
+ - src/rubyjs/lib
80
+ - src/rubyjs/lib/json.rb
81
+ - src/rubyjs/lib/core.rb
82
+ - src/rubyjs/compiler.rb
83
+ - src/rubyjs/name_generator.rb
84
+ - utils
85
+ - utils/jsc
86
+ - utils/jsc/README
87
+ - utils/jsc/run.sh
88
+ - utils/jsc/RunScript.c
89
+ - utils/jsc/Makefile
90
+ - utils/js
91
+ - utils/js/js.jar
92
+ - utils/js/RunScript.class
93
+ - utils/js/Makefile
94
+ - utils/js/RunScript.java
95
+ - utils/js/run.sh
96
+ - utils/yuicompressor
97
+ - utils/yuicompressor/yuicompressor-2.2.5.jar
98
+ - utils/yuicompressor/README
99
+ - bin
100
+ - bin/rubyjs
74
101
  - rubyjs.gemspec
102
+ - patches
103
+ - patches/parse_tree.rb.diff
75
104
  - vendor
76
- - vendor/ParseTree-1.7.1
77
- - vendor/ParseTree-1.7.1/Manifest.txt
78
- - vendor/ParseTree-1.7.1/lib
79
- - vendor/ParseTree-1.7.1/lib/sexp_processor.rb
80
- - vendor/ParseTree-1.7.1/lib/composite_sexp_processor.rb
81
- - vendor/ParseTree-1.7.1/lib/parse_tree.rb
82
- - vendor/ParseTree-1.7.1/lib/sexp.rb
83
- - vendor/ParseTree-1.7.1/lib/unique.rb
84
- - vendor/ParseTree-1.7.1/Rakefile
85
- - vendor/ParseTree-1.7.1/validate.sh
86
- - vendor/ParseTree-1.7.1/test
87
- - vendor/ParseTree-1.7.1/test/test_composite_sexp_processor.rb
88
- - vendor/ParseTree-1.7.1/test/test_sexp_processor.rb
89
- - vendor/ParseTree-1.7.1/test/pt_testcase.rb
90
- - vendor/ParseTree-1.7.1/test/test_all.rb
91
- - vendor/ParseTree-1.7.1/test/something.rb
92
- - vendor/ParseTree-1.7.1/test/test_sexp.rb
93
- - vendor/ParseTree-1.7.1/test/test_parse_tree.rb
94
- - vendor/ParseTree-1.7.1/History.txt
95
- - vendor/ParseTree-1.7.1/bin
96
- - vendor/ParseTree-1.7.1/bin/parse_tree_show
97
- - vendor/ParseTree-1.7.1/bin/parse_tree_abc
98
- - vendor/ParseTree-1.7.1/bin/parse_tree_deps
99
- - vendor/ParseTree-1.7.1/bin/parse_tree_audit
100
- - vendor/ParseTree-1.7.1/README.txt
101
- - vendor/ParseTree-1.7.1/demo
102
- - vendor/ParseTree-1.7.1/demo/printer.rb
103
105
  - vendor/ParseTree-1.7.1-patched
104
- - vendor/ParseTree-1.7.1-patched/validate.sh
105
106
  - vendor/ParseTree-1.7.1-patched/Rakefile
106
- - vendor/ParseTree-1.7.1-patched/README.txt
107
- - vendor/ParseTree-1.7.1-patched/Manifest.txt
108
- - vendor/ParseTree-1.7.1-patched/History.txt
109
107
  - vendor/ParseTree-1.7.1-patched/demo
110
108
  - vendor/ParseTree-1.7.1-patched/demo/printer.rb
109
+ - vendor/ParseTree-1.7.1-patched/README.txt
111
110
  - vendor/ParseTree-1.7.1-patched/test
112
- - vendor/ParseTree-1.7.1-patched/test/test_composite_sexp_processor.rb
113
- - vendor/ParseTree-1.7.1-patched/test/test_parse_tree.rb
114
- - vendor/ParseTree-1.7.1-patched/test/test_all.rb
115
111
  - vendor/ParseTree-1.7.1-patched/test/pt_testcase.rb
116
112
  - vendor/ParseTree-1.7.1-patched/test/test_sexp_processor.rb
113
+ - vendor/ParseTree-1.7.1-patched/test/test_all.rb
114
+ - vendor/ParseTree-1.7.1-patched/test/test_parse_tree.rb
117
115
  - vendor/ParseTree-1.7.1-patched/test/test_sexp.rb
118
116
  - vendor/ParseTree-1.7.1-patched/test/something.rb
117
+ - vendor/ParseTree-1.7.1-patched/test/test_composite_sexp_processor.rb
118
+ - vendor/ParseTree-1.7.1-patched/validate.sh
119
119
  - vendor/ParseTree-1.7.1-patched/lib
120
120
  - vendor/ParseTree-1.7.1-patched/lib/composite_sexp_processor.rb
121
- - vendor/ParseTree-1.7.1-patched/lib/sexp_processor.rb
122
- - vendor/ParseTree-1.7.1-patched/lib/sexp.rb
123
121
  - vendor/ParseTree-1.7.1-patched/lib/parse_tree.rb
122
+ - vendor/ParseTree-1.7.1-patched/lib/sexp_processor.rb
124
123
  - vendor/ParseTree-1.7.1-patched/lib/unique.rb
124
+ - vendor/ParseTree-1.7.1-patched/lib/sexp.rb
125
125
  - vendor/ParseTree-1.7.1-patched/bin
126
- - vendor/ParseTree-1.7.1-patched/bin/parse_tree_deps
127
- - vendor/ParseTree-1.7.1-patched/bin/parse_tree_audit
128
126
  - vendor/ParseTree-1.7.1-patched/bin/parse_tree_abc
129
127
  - vendor/ParseTree-1.7.1-patched/bin/parse_tree_show
128
+ - vendor/ParseTree-1.7.1-patched/bin/parse_tree_deps
129
+ - vendor/ParseTree-1.7.1-patched/bin/parse_tree_audit
130
+ - vendor/ParseTree-1.7.1-patched/History.txt
131
+ - vendor/ParseTree-1.7.1-patched/Manifest.txt
132
+ - vendor/ParseTree-1.7.1
133
+ - vendor/ParseTree-1.7.1/demo
134
+ - vendor/ParseTree-1.7.1/demo/printer.rb
135
+ - vendor/ParseTree-1.7.1/lib
136
+ - vendor/ParseTree-1.7.1/lib/parse_tree.rb
137
+ - vendor/ParseTree-1.7.1/lib/sexp.rb
138
+ - vendor/ParseTree-1.7.1/lib/sexp_processor.rb
139
+ - vendor/ParseTree-1.7.1/lib/unique.rb
140
+ - vendor/ParseTree-1.7.1/lib/composite_sexp_processor.rb
141
+ - vendor/ParseTree-1.7.1/README.txt
142
+ - vendor/ParseTree-1.7.1/Rakefile
143
+ - vendor/ParseTree-1.7.1/bin
144
+ - vendor/ParseTree-1.7.1/bin/parse_tree_deps
145
+ - vendor/ParseTree-1.7.1/bin/parse_tree_audit
146
+ - vendor/ParseTree-1.7.1/bin/parse_tree_show
147
+ - vendor/ParseTree-1.7.1/bin/parse_tree_abc
148
+ - vendor/ParseTree-1.7.1/History.txt
149
+ - vendor/ParseTree-1.7.1/test
150
+ - vendor/ParseTree-1.7.1/test/test_sexp_processor.rb
151
+ - vendor/ParseTree-1.7.1/test/test_all.rb
152
+ - vendor/ParseTree-1.7.1/test/pt_testcase.rb
153
+ - vendor/ParseTree-1.7.1/test/test_parse_tree.rb
154
+ - vendor/ParseTree-1.7.1/test/something.rb
155
+ - vendor/ParseTree-1.7.1/test/test_sexp.rb
156
+ - vendor/ParseTree-1.7.1/test/test_composite_sexp_processor.rb
157
+ - vendor/ParseTree-1.7.1/Manifest.txt
158
+ - vendor/ParseTree-1.7.1/validate.sh
130
159
  - README
131
160
  - test
132
- - test/test_send.rb
133
- - test/common.rb
134
- - test/test_new.rb
135
- - test/test_args.rb
136
- - test/run_tests.rb
137
- - test/gen_browser_test_suite.rb
138
- - test/test_array.rb
139
- - test/common.Browser.rb
140
- - test/gen_test_suite.rb
141
- - test/browser.test.html
142
- - test/test_eql.rb
143
- - test/test_string.rb
144
- - test/run_benchs.rb
145
- - test/test_range.rb
146
- - test/test_exception.rb
161
+ - test/test_lebewesen.rb
162
+ - test/test_hot_ruby.rb
163
+ - test/test_yield.rb
147
164
  - test/benchmark
165
+ - test/benchmark/bm_vm1_const.js
166
+ - test/benchmark/common.rb
148
167
  - test/benchmark/bm_vm1_ensure.js
149
168
  - test/benchmark/bm_vm1_block.rb
150
- - test/benchmark/bm_vm1_const.js
151
- - test/benchmark/common.js
169
+ - test/benchmark/params.yaml
170
+ - test/benchmark/bm_vm1_block.js
171
+ - test/benchmark/bm_vm1_ensure.rb
152
172
  - test/benchmark/bm_var_acc1.js
153
- - test/benchmark/bm_call_conv1.js
154
- - test/benchmark/bm_var_acc2.js
155
- - test/benchmark/common.rb
156
173
  - test/benchmark/bm_call_conv2.js
174
+ - test/benchmark/common.js
175
+ - test/benchmark/bm_var_acc2.js
157
176
  - test/benchmark/bm_vm1_const.rb
158
- - test/benchmark/bm_vm1_block.js
159
- - test/benchmark/params.yaml
160
- - test/benchmark/bm_vm1_ensure.rb
177
+ - test/benchmark/bm_call_conv1.js
178
+ - test/test_simple_output.rb
161
179
  - test/test_massign.rb
162
180
  - test/test_regexp.rb
163
- - test/test_yield.rb
164
- - test/test_hash.rb
165
- - test/test_if.rb
181
+ - test/run_tests.rb
182
+ - test/test_args.rb
183
+ - test/test_class.rb
184
+ - test/test_send.rb
166
185
  - test/browser.test.js
167
- - test/test_simple_output.rb
168
- - test/test_lebewesen.rb
169
- - test/test_inspect.rb
170
186
  - test/test_splat.rb
171
- - test/test_case.rb
187
+ - test/test_inspect.rb
188
+ - test/test_array.rb
189
+ - test/browser.test.html
172
190
  - test/test_expr.rb
173
- - test/test_class.rb
174
- - utils
175
- - utils/yuicompressor
176
- - utils/yuicompressor/README
177
- - utils/yuicompressor/yuicompressor-2.2.5.jar
178
- - utils/js
179
- - utils/js/Makefile
180
- - utils/js/RunScript.class
181
- - utils/js/RunScript.java
182
- - utils/js/run.sh
183
- - utils/js/js.jar
184
- - utils/jsc
185
- - utils/jsc/README
186
- - utils/jsc/run.sh
187
- - utils/jsc/RunScript.c
188
- - utils/jsc/Makefile
189
- - patches
190
- - patches/parse_tree.rb.diff
191
- - examples
192
- - examples/ex1
193
- - examples/ex1/ex1.js
194
- - examples/ex1/index.html
195
- - examples/ex1/Rakefile
196
- - examples/ex1/ex1.rb
197
- - examples/hw
198
- - examples/hw/hw.rb
199
- - examples/hw/index.html
200
- - examples/hw/Rakefile
201
- - examples/hw/hw.js
202
- - Rakefile
191
+ - test/gen_test_suite.rb
192
+ - test/common.rb
193
+ - test/test_exception.rb
194
+ - test/test_case.rb
195
+ - test/gen_browser_test_suite.rb
196
+ - test/test_eql.rb
197
+ - test/test_if.rb
198
+ - test/test_string.rb
199
+ - test/run_benchs.rb
200
+ - test/test_hash.rb
201
+ - test/test_insertion_sort.rb
202
+ - test/test_range.rb
203
+ - test/common.Browser.rb
204
+ - test/test_new.rb
203
205
  has_rdoc: false
204
206
  homepage: http://rubyforge.org/projects/rubyjs
205
207
  post_install_message: