rubyjs 0.7.1 → 0.8.0

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.
Files changed (61) hide show
  1. data/examples/client_server/README +18 -0
  2. data/examples/client_server/Rakefile +5 -0
  3. data/examples/client_server/client.js +749 -0
  4. data/examples/client_server/client.rb +12 -0
  5. data/examples/client_server/index.html +7 -0
  6. data/examples/client_server/server.rb +17 -0
  7. data/examples/hw/hw.js +234 -216
  8. data/rubyjs.gemspec +2 -2
  9. data/src/rubyjs.rb +0 -1
  10. data/src/rubyjs/compiler.rb +21 -8
  11. data/src/rubyjs/debug_name_generator.rb +23 -6
  12. data/src/rubyjs/model.rb +14 -8
  13. data/test/browser.test.html +1 -1
  14. data/test/browser.test.js +2337 -1992
  15. data/test/test_yield.rb +2 -0
  16. metadata +108 -158
  17. data/patches/parse_tree.rb.diff +0 -34
  18. data/vendor/ParseTree-1.7.1-patched/History.txt +0 -217
  19. data/vendor/ParseTree-1.7.1-patched/Manifest.txt +0 -22
  20. data/vendor/ParseTree-1.7.1-patched/README.txt +0 -110
  21. data/vendor/ParseTree-1.7.1-patched/Rakefile +0 -41
  22. data/vendor/ParseTree-1.7.1-patched/bin/parse_tree_abc +0 -89
  23. data/vendor/ParseTree-1.7.1-patched/bin/parse_tree_audit +0 -28
  24. data/vendor/ParseTree-1.7.1-patched/bin/parse_tree_deps +0 -62
  25. data/vendor/ParseTree-1.7.1-patched/bin/parse_tree_show +0 -49
  26. data/vendor/ParseTree-1.7.1-patched/demo/printer.rb +0 -20
  27. data/vendor/ParseTree-1.7.1-patched/lib/composite_sexp_processor.rb +0 -49
  28. data/vendor/ParseTree-1.7.1-patched/lib/parse_tree.rb +0 -1013
  29. data/vendor/ParseTree-1.7.1-patched/lib/sexp.rb +0 -235
  30. data/vendor/ParseTree-1.7.1-patched/lib/sexp_processor.rb +0 -330
  31. data/vendor/ParseTree-1.7.1-patched/lib/unique.rb +0 -15
  32. data/vendor/ParseTree-1.7.1-patched/test/pt_testcase.rb +0 -1221
  33. data/vendor/ParseTree-1.7.1-patched/test/something.rb +0 -53
  34. data/vendor/ParseTree-1.7.1-patched/test/test_all.rb +0 -13
  35. data/vendor/ParseTree-1.7.1-patched/test/test_composite_sexp_processor.rb +0 -69
  36. data/vendor/ParseTree-1.7.1-patched/test/test_parse_tree.rb +0 -216
  37. data/vendor/ParseTree-1.7.1-patched/test/test_sexp.rb +0 -291
  38. data/vendor/ParseTree-1.7.1-patched/test/test_sexp_processor.rb +0 -244
  39. data/vendor/ParseTree-1.7.1-patched/validate.sh +0 -31
  40. data/vendor/ParseTree-1.7.1/History.txt +0 -217
  41. data/vendor/ParseTree-1.7.1/Manifest.txt +0 -22
  42. data/vendor/ParseTree-1.7.1/README.txt +0 -110
  43. data/vendor/ParseTree-1.7.1/Rakefile +0 -41
  44. data/vendor/ParseTree-1.7.1/bin/parse_tree_abc +0 -89
  45. data/vendor/ParseTree-1.7.1/bin/parse_tree_audit +0 -28
  46. data/vendor/ParseTree-1.7.1/bin/parse_tree_deps +0 -62
  47. data/vendor/ParseTree-1.7.1/bin/parse_tree_show +0 -49
  48. data/vendor/ParseTree-1.7.1/demo/printer.rb +0 -20
  49. data/vendor/ParseTree-1.7.1/lib/composite_sexp_processor.rb +0 -49
  50. data/vendor/ParseTree-1.7.1/lib/parse_tree.rb +0 -1004
  51. data/vendor/ParseTree-1.7.1/lib/sexp.rb +0 -235
  52. data/vendor/ParseTree-1.7.1/lib/sexp_processor.rb +0 -330
  53. data/vendor/ParseTree-1.7.1/lib/unique.rb +0 -15
  54. data/vendor/ParseTree-1.7.1/test/pt_testcase.rb +0 -1221
  55. data/vendor/ParseTree-1.7.1/test/something.rb +0 -53
  56. data/vendor/ParseTree-1.7.1/test/test_all.rb +0 -13
  57. data/vendor/ParseTree-1.7.1/test/test_composite_sexp_processor.rb +0 -69
  58. data/vendor/ParseTree-1.7.1/test/test_parse_tree.rb +0 -216
  59. data/vendor/ParseTree-1.7.1/test/test_sexp.rb +0 -291
  60. data/vendor/ParseTree-1.7.1/test/test_sexp_processor.rb +0 -244
  61. data/vendor/ParseTree-1.7.1/validate.sh +0 -31
@@ -1,244 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- $TESTING = true
4
-
5
- require 'sexp_processor'
6
- require 'stringio'
7
- require 'test/unit'
8
- require 'pp'
9
-
10
- # Fake test classes:
11
-
12
- class TestProcessor < SexpProcessor # ZenTest SKIP
13
- attr_accessor :auto_shift_type
14
-
15
- def process_acc1(exp)
16
- out = self.expected.new(:acc2, exp.thing_three, exp.thing_two, exp.thing_one)
17
- exp.clear
18
- return out
19
- end
20
-
21
- def process_acc2(exp)
22
- out = []
23
- out << exp.thing_one
24
- end
25
-
26
- def process_specific(exp)
27
- result = exp[1..-1]
28
- exp.clear
29
- self.expected.new(*result)
30
- end
31
-
32
- def process_strip(exp)
33
- result = exp.deep_clone
34
- exp.clear
35
- result
36
- end
37
-
38
- def process_nonempty(exp)
39
- s(*exp)
40
- end
41
-
42
- def process_broken(exp)
43
- result = [*exp]
44
- exp.clear
45
- result
46
- end
47
-
48
- def process_expected(exp)
49
- exp.clear
50
- return {}
51
- end
52
-
53
- def process_string(exp)
54
- return exp.shift
55
- end
56
-
57
- def rewrite_rewritable(exp) # (a b c) => (a c b)
58
- return s(exp.shift, exp.pop, exp.shift)
59
- end
60
-
61
- def process_rewritable(exp)
62
- return s(exp.shift, exp.shift == 2, exp.shift == 1)
63
- end
64
- end
65
-
66
- class TestProcessorDefault < SexpProcessor # ZenTest SKIP
67
- def initialize
68
- super
69
- self.default_method = :def_method
70
- end
71
-
72
- def def_method(exp)
73
- exp.clear
74
- self.expected.new(42)
75
- end
76
- end
77
-
78
- # Real test classes:
79
-
80
- class TestSexpProcessor < Test::Unit::TestCase
81
-
82
- def setup
83
- @processor = TestProcessor.new
84
- end
85
-
86
- def test_process_specific
87
- a = [:specific, 1, 2, 3]
88
- expected = a[1..-1]
89
- assert_equal(expected, @processor.process(a))
90
- end
91
-
92
- def test_process_general
93
- a = [:blah, 1, 2, 3]
94
- expected = a.deep_clone
95
- assert_equal(expected, @processor.process(a))
96
- end
97
-
98
- def test_process_default
99
- @processor = TestProcessorDefault.new
100
- @processor.warn_on_default = false
101
-
102
- a = s(:blah, 1, 2, 3)
103
- assert_equal(@processor.expected.new(42), @processor.process(a))
104
- end
105
-
106
- def test_process_not_sexp
107
- @processor = TestProcessor.new
108
- @processor.warn_on_default = false
109
-
110
- assert_raises(SexpTypeError) do
111
- @processor.process([:broken, 1, 2, 3])
112
- end
113
- end
114
-
115
- def test_process_unsupported_wrong
116
- @processor = TestProcessor.new
117
- @processor.unsupported << :strip
118
-
119
- assert_raises(UnsupportedNodeError) do
120
- @processor.process([:whatever])
121
- end
122
- end
123
-
124
- def test_unsupported_equal
125
- @processor.strict = true
126
- @processor.unsupported = [ :unsupported ]
127
- assert_raises(UnsupportedNodeError) do
128
- @processor.process([:unsupported, 42])
129
- end
130
- end
131
-
132
- def test_strict
133
- @processor.strict = true
134
- assert_raise(UnknownNodeError) do
135
- @processor.process([:blah, 1, 2, 3])
136
- end
137
- end
138
- def test_strict=; end #Handled
139
-
140
- def test_require_empty_false
141
- @processor.require_empty = false
142
-
143
- assert_nothing_raised do
144
- @processor.process([:nonempty, 1, 2, 3])
145
- end
146
- end
147
-
148
- def test_require_empty_true
149
- assert_raise(NotEmptyError) do
150
- @processor.process([:nonempty, 1, 2, 3])
151
- end
152
- end
153
- def test_require_empty=; end # handled
154
-
155
- def test_process_strip
156
- @processor.auto_shift_type = true
157
- assert_equal([1, 2, 3], @processor.process(s(:strip, 1, 2, 3)))
158
- end
159
-
160
- def test_rewrite
161
- assert_equal(s(:rewritable, :b, :a),
162
- @processor.rewrite(s(:rewritable, :a, :b)))
163
- end
164
-
165
- def test_rewrite_deep
166
- assert_equal(s(:specific, s(:rewritable, :b, :a)),
167
- @processor.rewrite(s(:specific, s(:rewritable, :a, :b))))
168
- end
169
-
170
- def test_process_rewrite
171
- assert_equal(s(:rewritable, true, true),
172
- @processor.process(s(:rewritable, 1, 2)))
173
- end
174
-
175
- def test_process_rewrite_deep
176
- assert_equal(s(s(:rewritable, :b, :a)),
177
- @processor.process(s(:specific, s(:rewritable, :a, :b))))
178
- end
179
-
180
- def test_process_rewrite_not_empty
181
- assert_raise(NotEmptyError) do
182
- @processor.process(s(:rewritable, 1, 2, 2))
183
- end
184
- end
185
-
186
- def test_assert_type_hit
187
- assert_nothing_raised do
188
- @processor.assert_type([:blah, 1, 2, 3], :blah)
189
- end
190
- end
191
-
192
- def test_assert_type_miss
193
- assert_raise(SexpTypeError) do
194
- @processor.assert_type([:thingy, 1, 2, 3], :blah)
195
- end
196
- end
197
-
198
- def test_generate
199
- # nothing to test at this time... soon.
200
- end
201
-
202
- def test_auto_shift_type
203
- @processor.auto_shift_type = false
204
- assert_equal(false, @processor.auto_shift_type)
205
- @processor.auto_shift_type = true
206
- assert_equal(true, @processor.auto_shift_type)
207
- end
208
- def test_auto_shift_type_equal; end # handled
209
-
210
- def test_default_method
211
- # default functionality tested in process_default
212
- assert_nil @processor.default_method
213
- @processor.default_method = :something
214
- assert_equal :something, @processor.default_method
215
- end
216
- def test_default_method=; end # handled
217
-
218
- def test_expected
219
- assert_equal Sexp, @processor.expected
220
- assert_raises(SexpTypeError) do
221
- @processor.process([:expected]) # should raise
222
- end
223
-
224
- @processor.process(s(:str, "string")) # shouldn't raise
225
-
226
- @processor.expected = Hash
227
- assert_equal Hash, @processor.expected
228
- assert !(Hash === s()), "Hash === s() should not be true"
229
-
230
- assert_raises(SexpTypeError) do
231
- @processor.process(s(:string, "string")) # should raise
232
- end
233
-
234
- @processor.process([:expected]) # shouldn't raise
235
- end
236
- def test_expected=; end # handled
237
-
238
- # Not Testing:
239
- def test_debug; end
240
- def test_debug=; end
241
- def test_warn_on_default; end
242
- def test_warn_on_default=; end
243
-
244
- end
@@ -1,31 +0,0 @@
1
- #!/bin/bash
2
-
3
- # set -xv
4
-
5
- trap "exit 1" 1 2 3 15
6
-
7
- DIRS="-I../../metaruby/dev/tests/builtin -I../../metaruby/dev/tests -Ilib"
8
- for d in $(ls -d ../../*/dev); do
9
- DIRS="-I$d $DIRS"
10
- done
11
-
12
- if [ -f rb.bad.txt ]; then
13
- mv rb.bad.txt rb.files.txt
14
- else
15
- find ../../*/dev /usr/local/lib/ruby/1.8/ -name \*.rb > rb.files.txt
16
- fi
17
-
18
- total_count=$(wc -l rb.files.txt | awk '{print $1}')
19
- curr_count=0
20
- for f in $(cat rb.files.txt); do
21
- curr_count=$(($curr_count + 1))
22
- if GEM_SKIP=ParseTree ruby $DIRS ./bin/parse_tree_show -q $f > /dev/null 2> rb.err.txt < /dev/null; then
23
- echo $f >> rb.good.txt
24
- status=pass
25
- else
26
- echo $f >> rb.bad.txt
27
- status=fail
28
- fi
29
- fname=`basename $f`
30
- printf "%4d/%4d: %s %s\n" $curr_count $total_count $status $fname
31
- done
@@ -1,217 +0,0 @@
1
- === 1.7.1 / 2007-06-05
2
-
3
- * 3 minor enhancements:
4
- * Added begin/rescue/ensure test.
5
- * Added block_pass_args_and_splat.
6
- * Allow methods to be pulled from unparsed files.
7
- * 1 bug fix:
8
- * Compatibility fixed across 1.8.
9
-
10
- === 1.7.0 / 2007-02-13
11
-
12
- * 2 major enhancements:
13
- * rewrite extracted and intended to be run before (or in front of) process.
14
- * rewrite is now recursive as well, so children rewritings should be
15
- done independently of their parents. This should make complex
16
- rewriting layers much cleaner and allow me to eventually collect
17
- and publish a single "standard" rewriting layer.
18
- * 1 minor enhancement:
19
- * Iters are now {} if short and one line. YAY!
20
- * 1 bug fix:
21
- * Added test cases brought out by ruby2ruby/heckle.
22
-
23
- === 1.6.4 / 2007-01-15
24
-
25
- * 1 minor enhancement:
26
- * Switched short if/unless to 1 line expressions.
27
- * 2 bug fixes:
28
- * Fixed the nested case/when bug. YAY!
29
- * Added dasgn_curr and defn_rescue test cases.
30
-
31
- === 1.6.3 / 2006-12-20
32
-
33
- * 1 bug fix:
34
- * ParseTree::translate was trying to translate inherited class methods.
35
-
36
- === 1.6.2 / 2006-12-19
37
-
38
- * 2 minor enhancements:
39
- * ParseTree::translate can now take :"self.method".
40
- * Improved PT tests for [], []=
41
- * 1 bug fixes:
42
- * Fixed a bug in ParseTree where cases w/o exprs were malformed.
43
-
44
- === 1.6.1 / 2006-11-11
45
-
46
- * 2 minor enhancements:
47
- * Have been going insane on the tests, expect more soon.
48
- * Cleaned up using named nodes, now do: args = exp.scope.block.args(:delete).
49
- * 2 bug fixes:
50
- * Fixed #parse_tree to return superclass in :const node.
51
- * Fixed while/until with no bodies (now nil).
52
-
53
- === 1.6.0 / 2006-10-11
54
-
55
- * 2 major enhancements:
56
- * PTTC just got a major enema. 2k lines o' diff.
57
- * All in all, removed 829 lines of code and made it a lot more solid.
58
- * 6 minor enhancements:
59
- * Added sort rake task.
60
- * Added a basic front-end method to ParseTree: translate, takes
61
- string or Class and optional method name.
62
- * Class now has nil for unspecified superclass. No way to tell if it
63
- is being reopened.
64
- * SexpProcessor's unsupported array now defaults to all the internal nodes.
65
- * Added Unique from ruby2c project.
66
- * something.rb got slimmed down to near nothing. About to be retired.
67
- * 3 bug fixes:
68
- * Added changeset to Hoe spec.
69
- * Fixed up description to use paragraphs_of.
70
- * Fixed op_asgn1, alias, undef, dsym, match.
71
-
72
- === 1.5.0 / 2006-09-24
73
-
74
- * 5 minor enhancements:
75
- * Added parse_tree_audit.
76
- * Added reporting of unsupported nodes that have processors.
77
- * YAY! class method support! generated as :"self.blah"
78
- * Add parse_tree_for_string.
79
- * Converted Rakefile+gemspec to Hoe-based Rakefile.
80
- * 6 bug fixes:
81
- * Did some preliminary work on 1.9 compatibility.
82
- * Fixed tests for some changes/clarifications.
83
- * Fixed resbody: should have nil exceptions list when no exception rescued.
84
- * Fixed op_asgn1 and op_asgn2.
85
- * Fixed incompatibility with new inline changes.
86
- * Fixed VALUE decl in parse_tree.rb
87
-
88
- === 1.4.1 / 2006-04-10
89
-
90
- * 4 minor enhancements:
91
- * parse_tree_show -f output is much cleaner now.
92
- * ParseTree does a much more elegant job of handling different versions.
93
- * ParseTree now has all node names in ParseTree::NODE_NAMES.
94
- * ParseTree now raises exceptions instead of freakin'.
95
- * 3 bug fixes:
96
- * Used multiruby to test against 1.8.2-4, 1.8 cvs, and 1.9 cvs.
97
- * Fixed incompatibilites introduced in ruby 1.8.4.
98
- * Fixed some incompatibilites introduced in ruby 1.9.x.
99
-
100
- === 1.4.0 / 2005-10-15
101
-
102
- * 5 minor enhancements
103
- * Improved Makefile's install rule, uninstall, and added FILTER to all.
104
- * Fixed minor issues w/ Makefile.
105
- * Added -I=loadpath to parse_tree_abc.
106
- * Added *args support for methods.
107
- * Split out sexp to its own file.
108
- * 2 bug fixes
109
- * Fixed weird bug in parse_tree_deps where sort was failing on deps.
110
- * ! Fixed fatal bug in parse_tree.rb caused by safe_level fix in ruby 1.8.3.
111
-
112
- === 1.3.8 / 2005-09-27
113
-
114
- * 1 bug fix:
115
- * Our private version of struct METHOD went out of sync w/ latest ruby.
116
- * Only use this if you are on 1.8.3+.
117
-
118
- === 1.3.7 / 2005-07-13
119
-
120
- * 3 bug fixes:
121
- * Fixed rubygem requires for non-gem systems.
122
- * Renamed on to on_error_in to make more clear.
123
- * Moved exceptions to their own tree to make catching cleaner.
124
-
125
- === 1.3.6 / 2005-05-19
126
-
127
- * 2 minor enhancements:
128
- * Improved debugging capability when $DEBUG.
129
- * Allowed for selective debugging output by node type.
130
- * 3 bug fixes:
131
- * Minor fixes to Makefile and parse_tree_show.
132
- * Improved error messages in parse_tree when newlines are included.
133
- * Improved method coverage for parse_tree.
134
-
135
- === 1.3.5 / 2005-04-19
136
-
137
- * 2 minor enhancement
138
- * Added dynamic exception handling on a per node-type basis (BIG).
139
- * Added -c=classname to parse_tree_show to help w/ core classes.
140
- * 1 bug fix
141
- * Fixed dependency specification error in gemspec.
142
-
143
- === 1.3.4 / 2005-02-09
144
-
145
- * 2 bug fixes
146
- * bug:1459: Cleaned up and corrected superclass naming code.
147
- * bug:1458: Fixed while to support post-conditional while/until nodes.
148
-
149
- === 1.3.3 / 2005-02-01
150
-
151
- * 3 minor enhancement
152
- * Cleaned up parse_tree_abc output
153
- * Patched up null class names (delegate classes are weird!)
154
- * Added UnknownNodeError and switched SyntaxError over to it.
155
- * 2 bug fixes
156
- * Fixed BEGIN node handling to recurse instead of going flat.
157
- * FINALLY fixed the weird compiler errors seen on some versions of
158
- gcc 3.4.x related to type punned pointers.
159
-
160
- === 1.3.2 / 2005-01-04
161
-
162
- * 1 minor enhancement
163
- * Added total line to end of ABC metric report.
164
- * 1 bug fix
165
- * Updates for ruby 1.8.2 parse tree changes.
166
-
167
- === 1.3.1 / 2004-12-09
168
-
169
- * 1 minor enhancement
170
- * Added rewrite_<type> processing.
171
- * 2 bug fixes
172
- * Renamed SexpProcessor's #exclude to #unsupported.
173
- * Fixed a bus error when an attrasgn uses self.
174
- * Added support for cfunc now that we found a repro.
175
-
176
- === 1.3.0 / 2004-12-06
177
-
178
- * 3 minor enhancements
179
- * Finished supporting pretty much all nodes (that we can figger out).
180
- * If $DEBUG, or true passed to new, then we now output the :newline nodes.
181
- * We output much better extra debugging info if $DEBUG.
182
- * 1 bug fixes
183
- * Fixed README for new output style.
184
-
185
- === 1.2.0 / 2004-11-29
186
-
187
- * 9 minor enhancements
188
- * ParseTree now returns symbols for all data except in :str and :lit.
189
- * This WILL break existing code! (as if any exists)
190
- * ParseTree.parse_tree now takes a list of classes, no optional method.
191
- * ParseTree.parse_tree_for_method(klass, method) added.
192
- * ParseTree.parse_tree now returns a list of :class/:module nodes.
193
- * Added -f to parse_tree_show for uber fast demos.
194
- * Added -q to parse_tree_show to NOT use pp so it is mucho faster.
195
- * running with $DEBUG will trace the methods and nodes as processed.
196
- * Added rdoc to everything.
197
- * Gemified
198
- * 4 bug fixes
199
- * Bus error in iter/for nodes where arg list is empty now fixed.
200
- * Bus error when handling 'def method(*)' is now fixed.
201
- * Unnamed classes and superclasses (ugh) are now handled.
202
- * parse_tree_abc now enumerates actual types rather than every token.
203
-
204
- === 1.1.0 / 2004-11-12
205
-
206
- * 2 minor enhancement
207
- * Added SexpProcessor and CompositeSexpProcessor
208
- * Allowed show.rb to read from standard input.
209
- * 3 bug fixes
210
- * Fixed makefile issues for BSD's make - so dumb.
211
- * Added super as a call in abc.rb's metrics
212
- * Commented out a compiler flag to work with GCC 2.95.
213
-
214
- === 1.0.0 / 2004-11-06
215
-
216
- * 1 major enhancement
217
- * Birthday!