mirah 0.1.0.pre-java → 0.1.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/History.txt +736 -0
  2. data/README.md +71 -0
  3. data/Rakefile +227 -73
  4. data/examples/Fib.class +0 -0
  5. data/examples/macros/{string-each-char.mirah → string_each_char.mirah} +2 -3
  6. data/examples/simple_class.mirah +3 -3
  7. data/examples/{dynamic.mirah → simple_class.mirah~} +7 -12
  8. data/javalib/mirah-bootstrap.jar +0 -0
  9. data/javalib/mirah-builtins.jar +0 -0
  10. data/javalib/mirah-compiler.jar +0 -0
  11. data/javalib/mirah-parser.jar +0 -0
  12. data/javalib/mirah-util.jar +0 -0
  13. data/lib/mirah.rb +8 -1
  14. data/lib/mirah/ast.rb +1 -1
  15. data/lib/mirah/ast/scope.rb +16 -0
  16. data/lib/mirah/commands/base.rb +1 -3
  17. data/lib/mirah/compiler.rb +17 -3
  18. data/lib/mirah/errors.rb +10 -10
  19. data/lib/mirah/generator.rb +21 -9
  20. data/lib/mirah/jvm/compiler.rb +17 -0
  21. data/lib/mirah/jvm/compiler/base.rb +24 -5
  22. data/lib/mirah/jvm/compiler/jvm_bytecode.rb +83 -20
  23. data/lib/mirah/jvm/method_lookup.rb +43 -22
  24. data/lib/mirah/jvm/types.rb +1 -2
  25. data/lib/mirah/jvm/types/array_type.rb +1 -6
  26. data/lib/mirah/jvm/types/ast_ext.rb +31 -0
  27. data/lib/mirah/jvm/types/basic_types.rb +1 -2
  28. data/lib/mirah/jvm/types/boolean.rb +11 -10
  29. data/lib/mirah/jvm/types/extensions.rb +14 -5
  30. data/lib/mirah/jvm/types/factory.rb +128 -43
  31. data/lib/mirah/jvm/types/floats.rb +8 -10
  32. data/lib/mirah/jvm/types/integers.rb +16 -9
  33. data/lib/mirah/jvm/types/intrinsics.rb +17 -69
  34. data/lib/mirah/jvm/types/meta_type.rb +5 -0
  35. data/lib/mirah/jvm/types/methods.rb +317 -151
  36. data/lib/mirah/jvm/types/methods.rb~ +973 -0
  37. data/lib/mirah/jvm/types/number.rb +29 -6
  38. data/lib/mirah/jvm/types/primitive_type.rb +35 -7
  39. data/lib/mirah/jvm/types/source_mirror.rb +11 -6
  40. data/lib/mirah/jvm/types/type.rb +52 -0
  41. data/lib/mirah/jvm/types/type_definition.rb +8 -2
  42. data/lib/mirah/transform/ast_ext.rb +9 -31
  43. data/lib/mirah/transform/transformer.rb +1 -1
  44. data/lib/mirah/typer.rb +2 -1
  45. data/lib/mirah/util/argument_processor.rb +10 -14
  46. data/lib/mirah/util/argument_processor.rb~ +146 -0
  47. data/lib/mirah/util/compilation_state.rb +15 -9
  48. data/lib/mirah/util/process_errors.rb +8 -2
  49. data/lib/mirah/version.rb +2 -2
  50. data/lib/mirah_task.rb +0 -7
  51. data/test/core/typer_test.rb +21 -13
  52. data/test/core/util/argument_processor_test.rb +19 -19
  53. data/test/core/util/class_loader_test.rb +19 -4
  54. data/test/core/util/compilation_state_test.rb +38 -0
  55. data/test/fixtures/org/foo/LowerCaseInnerClass$inner.class +0 -0
  56. data/test/fixtures/org/foo/LowerCaseInnerClass.class +0 -0
  57. data/test/fixtures/org/foo/LowerCaseInnerClass.java +7 -0
  58. data/test/jvm/blocks_test.rb +50 -29
  59. data/test/jvm/bytecode_test_helper.rb +71 -57
  60. data/test/jvm/cast_test.rb +162 -0
  61. data/test/jvm/constructors_test.rb +48 -0
  62. data/test/jvm/enumerable_test.rb +136 -7
  63. data/test/jvm/example_test.rb +39 -0
  64. data/test/jvm/factory_test.rb +6 -0
  65. data/test/jvm/generics_test.rb +0 -5
  66. data/test/jvm/import_test.rb +81 -0
  67. data/test/jvm/interface_test.rb +113 -0
  68. data/test/jvm/java_typer_test.rb +57 -11
  69. data/test/jvm/jvm_commands_test.rb +24 -0
  70. data/test/jvm/jvm_compiler_test.rb +186 -370
  71. data/test/jvm/macros_test.rb +67 -6
  72. data/test/jvm/main_method_test.rb +1 -1
  73. data/test/jvm/mirror_compilation_test_helper.rb +24 -0
  74. data/test/jvm/new_backend_test_helper.rb +25 -0
  75. data/test/jvm/rescue_test.rb +153 -18
  76. data/test/jvm/string_test.rb +41 -0
  77. data/test/jvm/varargs_test.rb +65 -0
  78. data/test/mirrors/base_type_test.rb +96 -0
  79. data/test/mirrors/bytecode_mirror_test.rb +86 -0
  80. data/test/mirrors/generics_test.rb +776 -0
  81. data/test/mirrors/member_test.rb +69 -0
  82. data/test/mirrors/method_lookup_test.rb +574 -0
  83. data/test/mirrors/mirrors_test.rb +562 -0
  84. data/test/mirrors/simple_async_mirror_loader_test.rb +110 -0
  85. data/test/mirrors/simple_mirror_loader_test.rb +104 -0
  86. data/test/test_helper.rb +2 -1
  87. metadata +244 -217
  88. data/README.txt +0 -59
  89. data/javalib/dynalink-0.2.jar +0 -0
  90. data/lib/mirah/jvm/typer.rb +0 -177
  91. data/lib/mirah/jvm/types/dynamic_type.rb +0 -45
  92. data/lib/mirah/jvm/types/unreachable_type.rb +0 -27
@@ -0,0 +1,39 @@
1
+ # Copyright (c) 2013 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # these are here to make sure the examples still run.
17
+ #
18
+ class ExampleTest < Test::Unit::TestCase
19
+ def compile_ex name
20
+ filename = File.dirname(__FILE__) + "/../../examples/#{name}.mirah"
21
+ compile(open(filename).read).first
22
+ end
23
+
24
+ def example_test name, output
25
+ cls = compile_ex name
26
+ assert_output(output) { cls.main nil }
27
+ end
28
+
29
+ {
30
+ 'simple_class' => "constructor\nHello, \nMirah\n",
31
+ 'macros/square' => "2.0\n8.0\n",
32
+ 'macros/square_int' => "2.0\n8.0\n",
33
+ 'macros/string_each_char' => "l\na\na\nt\n \nd\ne\n \nl\ne\ne\ne\nu\nw\n \nn\ni\ne\nt\n \ni\nn\n \nz\ni\nj\nn\n \nh\ne\nm\np\ni\ne\n \ns\nt\na\na\nn\n"
34
+ }.each do |example,output|
35
+ define_method "test_#{example}" do
36
+ example_test example, output
37
+ end
38
+ end
39
+ end
@@ -19,4 +19,10 @@ class FactoryTest < Test::Unit::TestCase
19
19
  factory.bootclasspath = File.expand_path("#{__FILE__}/../../fixtures/") +"/"
20
20
  assert factory.bootstrap_loader.get_resource 'org/foo/A.class'
21
21
  end
22
+
23
+ def test_nil_classpath_is_ok
24
+ factory = Mirah::JVM::Types::TypeFactory.new
25
+ factory.classpath = nil
26
+ end
27
+
22
28
  end
@@ -17,11 +17,6 @@ require 'test_helper'
17
17
  require 'jvm/bytecode_test_helper'
18
18
  class TestGenerics < Test::Unit::TestCase
19
19
 
20
- def setup
21
- super
22
- clear_tmp_files
23
- end
24
-
25
20
  def parse_and_type code, name=tmp_script_name
26
21
  parse_and_resolve_types name, code
27
22
  end
@@ -0,0 +1,81 @@
1
+ # Copyright (c) 2013 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ class ImportTest < Test::Unit::TestCase
17
+
18
+ def test_quote_import
19
+ cls, = compile("import 'java.util.ArrayList'; def foo; ArrayList.new; end; foo")
20
+ assert_equal java.util.ArrayList.java_class, cls.foo.java_class
21
+ end
22
+
23
+ def test_no_quote_import
24
+ cls, = compile("import java.util.ArrayList; def foo; ArrayList.new; end; foo")
25
+ assert_equal java.util.ArrayList.java_class, cls.foo.java_class
26
+ end
27
+
28
+ def test_alias_import_as_syntax
29
+ cls, = compile("import java.util.ArrayList as AL; def foo; AL.new; end; foo")
30
+ assert_equal java.util.ArrayList.java_class, cls.foo.java_class
31
+ end
32
+
33
+ def test_alias_import_comma_syntax
34
+ cls, = compile("import 'AL', 'java.util.ArrayList'; def foo; AL.new; end; foo")
35
+ assert_equal java.util.ArrayList.java_class, cls.foo.java_class
36
+ end
37
+
38
+ def test_imported_decl
39
+ cls, = compile("import 'java.util.ArrayList'; def foo(a:ArrayList); a.size; end")
40
+ assert_equal 0, cls.foo(java.util.ArrayList.new)
41
+ end
42
+
43
+ def test_import_package_star
44
+ cls, = compile(<<-EOF)
45
+ import java.util.*
46
+ def foo
47
+ ArrayList.new
48
+ end
49
+ EOF
50
+ assert_equal java.util.ArrayList.java_class, cls.foo.java_class
51
+ end
52
+
53
+ def test_static_import
54
+ cls, = compile(<<-EOF)
55
+ import static java.util.Arrays.*
56
+ def list(x:Object[])
57
+ asList(x)
58
+ end
59
+ EOF
60
+
61
+ o = ["1", "2", "3"].to_java(:object)
62
+ list = cls.list(o)
63
+ assert_kind_of(Java::JavaUtil::List, list)
64
+ assert_equal(["1", "2", "3"], list.to_a)
65
+
66
+ cls, = compile(<<-EOF)
67
+ import java.util.Arrays
68
+ class StaticImports
69
+ import static Arrays.*
70
+ def list(x:Object[])
71
+ asList(x)
72
+ end
73
+ end
74
+ EOF
75
+
76
+ list = cls.new.list(o)
77
+ assert_kind_of(Java::JavaUtil::List, list)
78
+ assert_equal(["1", "2", "3"], list.to_a)
79
+ end
80
+
81
+ end
@@ -0,0 +1,113 @@
1
+ # Copyright (c) 2010-2013 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ class InterfaceTest < Test::Unit::TestCase
17
+ def test_interface
18
+ cls, = compile(<<-EOF)
19
+ import 'java.util.concurrent.Callable'
20
+ def foo(a:Callable)
21
+ a.call
22
+ end
23
+ EOF
24
+ result = cls.foo {0}
25
+ assert_equal 0, result
26
+ m = cls.java_class.java_method 'foo', java.util.concurrent.Callable
27
+ end
28
+
29
+ def test_interface_declaration
30
+ interface = compile('interface A; end').first
31
+ assert(interface.java_class.interface?)
32
+ assert_equal('A', interface.java_class.name)
33
+
34
+ a, b = compile('interface A; end; interface B < A; end')
35
+ assert_include(a, b.ancestors)
36
+ assert_equal('A', a.java_class.name)
37
+ assert_equal('B', b.java_class.name)
38
+
39
+ a, b, c = compile(<<-EOF)
40
+ interface A
41
+ end
42
+
43
+ interface B
44
+ end
45
+
46
+ interface C < A, B
47
+ end
48
+ EOF
49
+
50
+ assert_include(a, c.ancestors)
51
+ assert_include(b, c.ancestors)
52
+ assert_equal('A', a.java_class.name)
53
+ assert_equal('B', b.java_class.name)
54
+ assert_equal('C', c.java_class.name)
55
+ end
56
+
57
+ def test_interface_override_return_type
58
+ assert_raise_kind_of Mirah::MirahError do
59
+ compile(<<-EOF)
60
+ interface AnInterface
61
+ def a:int; end
62
+ end
63
+
64
+ class AImpl implements AnInterface
65
+ def a
66
+ "foo"
67
+ end
68
+ end
69
+ EOF
70
+ end
71
+ end
72
+
73
+ def test_interface_implementation_with_non_array_params_doesnt_require_type_information
74
+ interface, a_impl = compile(<<-EOF)
75
+ interface InterfaceWithStrings
76
+ def arr(message:String):int; end
77
+ end
78
+
79
+ class StringImpl implements InterfaceWithStrings
80
+ def blah(s:String) s.length ; end
81
+ def arr(message) blah message ; end
82
+ end
83
+ EOF
84
+ end
85
+
86
+ def test_interface_implementation_with_array_params_requires_type_information
87
+ interface, a_impl = compile(<<-EOF)
88
+ interface InterfaceWithArrays
89
+ def arr(messages:String[]):int; end
90
+ end
91
+
92
+ class ExplicitArrImpl implements InterfaceWithArrays
93
+ def blah(s:String[]) s.length ; end
94
+ def arr(messages:String[]) blah messages ; end
95
+ end
96
+ EOF
97
+
98
+ # this is the current behavior. I think we should fix it. nh
99
+ error = assert_raises Mirah::MirahError do
100
+ interface, a_impl = compile(<<-EOF)
101
+ interface InterfaceWithArrays
102
+ def arr(messages:String[]):int; end
103
+ end
104
+
105
+ class ImplicitArrImpl implements InterfaceWithArrays
106
+ def blah(s:String[]) s.length ; end
107
+ def arr(messages) blah messages ; end
108
+ end
109
+ EOF
110
+ end
111
+ assert_equal "Cannot find instance method blah(java.lang.String) on ImplicitArrImpl", error.message
112
+ end
113
+ end
@@ -28,12 +28,15 @@ class JavaTyperTest < Test::Unit::TestCase
28
28
  def setup
29
29
  @types = Mirah::JVM::Types::TypeFactory.new
30
30
  @scopes = SimpleScoper.new {|scoper, node| Mirah::AST::StaticScope.new(node, scoper)}
31
- @typer = Mirah::Typer::Typer.new(@types, @scopes, nil)
31
+ @typer = Mirah::Typer::Typer.new(@types, @scopes, nil, nil)
32
32
  @mirah = Mirah::Transform::Transformer.new(Mirah::Util::CompilationState.new, @typer)
33
33
  end
34
34
 
35
- def inferred_type(node)
36
- type = @typer.infer(node, false).resolve
35
+ def inferred_type(node, expression=false)
36
+ if node.kind_of? Java::MirahLangAst::Script
37
+ node = node.body
38
+ end
39
+ type = @typer.infer(node, expression).resolve
37
40
  if type.name == ':error'
38
41
  catch(:exit) do
39
42
  process_errors([type])
@@ -42,10 +45,21 @@ class JavaTyperTest < Test::Unit::TestCase
42
45
  type
43
46
  end
44
47
 
48
+ def assert_errors_including(message, ast)
49
+ @typer.infer(ast, false)
50
+ actual_errors = []
51
+ process_inference_errors(@typer, [ast]) do |errors|
52
+ actual_errors += errors.map {|e| e.message.map{|m| m[0]}.join("\n")}
53
+ end
54
+ fail("no errors") if actual_errors.empty?
55
+ assert actual_errors.any?{|error| error =~ message },
56
+ "no errors with message \"#{message}\" in #{actual_errors}"
57
+ end
58
+
45
59
  def method_type(target, name, args)
46
60
  target = @types.cache_and_wrap(target)
47
61
  args = args.map {|arg| @types.cache_and_wrap(arg) }
48
- call = CallFuture.new(@types, nil, target, name, args, nil, nil)
62
+ call = CallFuture.new(@types, nil, target, true, name, args, nil, nil)
49
63
  @types.getMethodType(call).return_type
50
64
  end
51
65
 
@@ -212,6 +226,14 @@ class JavaTyperTest < Test::Unit::TestCase
212
226
  assert_equal(@types.type(nil, 'byte'), method_type(ary, "[]", [int]).resolve)
213
227
  end
214
228
 
229
+
230
+ def test_primitive_not_convertible_to_array_with_same_component_type
231
+ ary = @types.type(nil, 'byte', true)
232
+ byte = @types.type(nil, 'byte')
233
+
234
+ assert !primitive_convertible?(byte, ary)
235
+ end
236
+
215
237
  def test_int
216
238
  ast = parse("#{1 << 16}")
217
239
  assert_equal(@types.type(nil, 'int'), inferred_type(ast))
@@ -221,17 +243,41 @@ class JavaTyperTest < Test::Unit::TestCase
221
243
  ast = parse("#{1 << 33}")
222
244
  assert_equal(@types.type(nil, 'long'), inferred_type(ast))
223
245
  end
224
-
225
- def test_dynamic_assignability
226
- ast = parse("a = 1; a = dynamic('foo')")
227
- assert_equal true, inferred_type(ast).isError
228
-
229
- ast = parse("a = Object.new; a = dynamic('foo')")
230
- assert_equal 'java.lang.Object', inferred_type(ast).name
246
+
247
+ def test_char
248
+ ast = parse("?a")
249
+ assert_equal(@types.type(nil, 'char'), inferred_type(ast))
231
250
  end
232
251
 
233
252
  def test_static_method
234
253
  ast = parse("class Foo;def self.bar; 1; end; end; Foo.bar")
235
254
  assert_equal(@types.type(nil, 'int'), inferred_type(ast))
236
255
  end
256
+
257
+ def test_if_with_raise_has_non_raise_type
258
+ ast = parse("if true; 1; else; raise 'error'; end")
259
+ assert_equal(@types.type(nil, 'int'), inferred_type(ast))
260
+ end
261
+
262
+ def test_rescue_with_raise_in_rescue_has_body_type
263
+ ast = parse("1 + begin; 1; rescue; raise 'error'; end")
264
+ assert_equal(@types.type(nil, 'int'), inferred_type(ast))
265
+ end
266
+
267
+ def test_rescue_with_else_and_raise_in_rescue_has_else_type
268
+ ast = parse("1 + begin; ''; rescue; raise 'error'; else 1 end")
269
+ assert_equal(@types.type(nil, 'int'), inferred_type(ast))
270
+ end
271
+
272
+ def test_type_cycle
273
+ ast = parse(<<-EOF)
274
+ def foo(a:String):Object
275
+ nil
276
+ end
277
+
278
+ a = "x"
279
+ a = foo(a)
280
+ EOF
281
+ assert_errors_including(/Cannot assign .*Object.* to .*String/, ast)
282
+ end
237
283
  end
@@ -0,0 +1,24 @@
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ require 'test_helper'
16
+
17
+
18
+ class JVMCommandsTest < Test::Unit::TestCase
19
+ def test_dash_e_eval
20
+ assert_output "1\n" do
21
+ Mirah::Commands::Run.new(['-e','puts 1']).execute
22
+ end
23
+ end
24
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
1
+ # Copyright (c) 2010-2013 The Mirah project authors. All Rights Reserved.
2
2
  # All contributing project authors may be found in the NOTICE file.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,13 +14,6 @@
14
14
  # limitations under the License.
15
15
 
16
16
  class JVMCompilerTest < Test::Unit::TestCase
17
- def assert_raise_java(type, message="")
18
- ex = assert_raise(NativeException) do
19
- yield
20
- end
21
- assert_equal type, ex.cause.class
22
- assert_equal message, ex.cause.message.to_s
23
- end
24
17
 
25
18
  def test_local
26
19
  cls, = compile("def foo; a = 1; a; end")
@@ -147,10 +140,9 @@ class JVMCompilerTest < Test::Unit::TestCase
147
140
  cls, = compile("def foo; a = char[2]; a; end")
148
141
  assert_equal(Java::char[].java_class, cls.foo.class.java_class)
149
142
  assert_equal([0,0], cls.foo.to_a)
150
- # Pending char constants or casts
151
- # cls, = compile("def foo; a = char[2]; a[0] = 1; a[0]; end")
152
- # assert_equal(Fixnum, cls.foo.class)
153
- # assert_equal(1, cls.foo)
143
+
144
+ cls, = compile("def foo; a = char[2]; a[0] = ?x; a[0]; end")
145
+ assert_equal(?x.ord, cls.foo)
154
146
 
155
147
  cls, = compile("def foo; a = int[2]; a; end")
156
148
  assert_equal(Java::int[].java_class, cls.foo.class.java_class)
@@ -206,29 +198,6 @@ class JVMCompilerTest < Test::Unit::TestCase
206
198
  assert_equal([nil, nil], cls.foo.to_a)
207
199
  end
208
200
 
209
- def test_string_concat
210
- cls, = compile("
211
- def str_str; a = 'a'; b = 'b'; a + b; end
212
- def str_boolean; a = 'a'; b = false; a + b; end
213
- def str_float; a = 'a'; b = float(1.0); a + b; end
214
- def str_double; a = 'a'; b = 1.0; a + b; end
215
- def str_byte; a = 'a'; b = byte(1); a + b; end
216
- def str_short; a = 'a'; b = short(1); a + b; end
217
- def str_char; a = 'a'; b = char(123); a + b; end
218
- def str_int; a = 'a'; b = 1; a + b; end
219
- def str_long; a = 'a'; b = long(1); a + b; end
220
- ")
221
- assert_equal("ab", cls.str_str)
222
- assert_equal("afalse", cls.str_boolean)
223
- assert_equal("a1.0", cls.str_float)
224
- assert_equal("a1.0", cls.str_double)
225
- assert_equal("a1", cls.str_byte)
226
- assert_equal("a1", cls.str_short)
227
- assert_equal("a{", cls.str_char)
228
- assert_equal("a1", cls.str_int)
229
- assert_equal("a1", cls.str_long)
230
- end
231
-
232
201
  def test_void_selfcall
233
202
  cls, = compile("import 'System', 'java.lang.System'; def foo; System.gc; end; foo")
234
203
  assert_nothing_raised {cls.foo}
@@ -266,61 +235,18 @@ class JVMCompilerTest < Test::Unit::TestCase
266
235
 
267
236
  end
268
237
 
269
- def test_import
270
- cls, = compile("import 'java.util.ArrayList'; def foo; ArrayList.new; end; foo")
271
- assert_equal java.util.ArrayList.java_class, cls.foo.java_class
272
-
273
- cls, = compile("import 'AL', 'java.util.ArrayList'; def foo; AL.new; end; foo")
274
- assert_equal java.util.ArrayList.java_class, cls.foo.java_class
275
- end
276
-
277
- def test_no_quote_import
278
- cls, = compile("import java.util.ArrayList as AL; def foo; AL.new; end; foo")
279
- assert_equal java.util.ArrayList.java_class, cls.foo.java_class
280
-
281
- cls, = compile("import java.util.ArrayList; def foo; ArrayList.new; end; foo")
282
- assert_equal java.util.ArrayList.java_class, cls.foo.java_class
283
- end
284
-
285
- def test_imported_decl
286
- cls, = compile("import 'java.util.ArrayList'; def foo(a:ArrayList); a.size; end")
287
- assert_equal 0, cls.foo(java.util.ArrayList.new)
288
- end
289
-
290
- def test_import_package
291
- cls, = compile(<<-EOF)
292
- import java.util.*
293
- def foo
294
- ArrayList.new
295
- end
296
- EOF
297
- assert_equal java.util.ArrayList.java_class, cls.foo.java_class
298
- end
299
-
300
- def test_interface
301
- cls, = compile(<<-EOF)
302
- import 'java.util.concurrent.Callable'
303
- def foo(a:Callable)
304
- a.call
305
- end
306
- EOF
307
- result = cls.foo {0}
308
- assert_equal 0, result
309
- m = cls.java_class.java_method 'foo', java.util.concurrent.Callable
310
- end
311
-
312
238
  def test_class_decl
313
239
  foo, = compile("class ClassDeclTest;end")
314
240
  assert_equal('ClassDeclTest', foo.java_class.name)
315
241
  end
316
242
 
317
243
  def test_class_name_from_file_with_underscore
318
- foo, = compile("System.out.println 'blah'", 'class_name_test.mirah')
244
+ foo, = compile("System.out.println 'blah'", :name => 'class_name_test.mirah')
319
245
  assert_equal('ClassNameTest', foo.java_class.name)
320
246
  end
321
247
 
322
248
  def test_class_name_from_file_with_dash
323
- foo, = compile("System.out.println 'blah'", 'class-dash-test.mirah')
249
+ foo, = compile("System.out.println 'blah'", :name => 'class-dash-test.mirah')
324
250
  assert_equal('ClassDashTest', foo.java_class.name)
325
251
  end
326
252
 
@@ -351,7 +277,7 @@ class JVMCompilerTest < Test::Unit::TestCase
351
277
 
352
278
  def test_unless_fixnum
353
279
  cls, = compile(<<-EOF)
354
- def foo(a:fixnum)
280
+ def foo(a:int)
355
281
  values = boolean[5]
356
282
  values[0] = true unless a < 0
357
283
  values[1] = true unless a <= 0
@@ -385,7 +311,7 @@ class JVMCompilerTest < Test::Unit::TestCase
385
311
 
386
312
  def test_if_fixnum
387
313
  cls, = compile(<<-EOF)
388
- def foo(a:fixnum)
314
+ def foo(a:int)
389
315
  if a < -5
390
316
  -6
391
317
  elsif a <= 0
@@ -462,7 +388,7 @@ class JVMCompilerTest < Test::Unit::TestCase
462
388
 
463
389
  def test_trailing_conditions
464
390
  cls, = compile(<<-EOF)
465
- def foo(a:fixnum)
391
+ def foo(a:int)
466
392
  return '+' if a > 0
467
393
  return '0' unless a < 0
468
394
  '-'
@@ -489,25 +415,25 @@ class JVMCompilerTest < Test::Unit::TestCase
489
415
 
490
416
  def test_loop
491
417
  cls, = compile(
492
- 'def foo(a:fixnum);while a > 0; a -= 1; System.out.println ".";end;end')
418
+ 'def foo(a:int);while a > 0; a -= 1; System.out.println ".";end;end')
493
419
  assert_equal('', capture_output{cls.foo(0)})
494
420
  assert_equal(".\n", capture_output{cls.foo(1)})
495
421
  assert_equal(".\n.\n", capture_output{cls.foo(2)})
496
422
 
497
423
  cls, = compile(
498
- 'def foo(a:fixnum);begin;a -= 1; System.out.println ".";end while a > 0;end')
424
+ 'def foo(a:int);begin;a -= 1; System.out.println ".";end while a > 0;end')
499
425
  assert_equal(".\n", capture_output{cls.foo(0)})
500
426
  assert_equal(".\n", capture_output{cls.foo(1)})
501
427
  assert_equal(".\n.\n", capture_output{cls.foo(2)})
502
428
 
503
429
  cls, = compile(
504
- 'def foo(a:fixnum);until a <= 0; a -= 1; System.out.println ".";end;end')
430
+ 'def foo(a:int);until a <= 0; a -= 1; System.out.println ".";end;end')
505
431
  assert_equal('', capture_output{cls.foo(0)})
506
432
  assert_equal(".\n", capture_output{cls.foo(1)})
507
433
  assert_equal(".\n.\n", capture_output{cls.foo(2)})
508
434
 
509
435
  cls, = compile(
510
- 'def foo(a:fixnum);begin;a -= 1; System.out.println ".";end until a <= 0;end')
436
+ 'def foo(a:int);begin;a -= 1; System.out.println ".";end until a <= 0;end')
511
437
  assert_equal(".\n", capture_output{cls.foo(0)})
512
438
  assert_equal(".\n", capture_output{cls.foo(1)})
513
439
  assert_equal(".\n.\n", capture_output{cls.foo(2)})
@@ -518,7 +444,7 @@ class JVMCompilerTest < Test::Unit::TestCase
518
444
 
519
445
  # TODO: loop doesn't work unless you're explicitly in a class
520
446
  # cls, = compile(<<-EOF)
521
- # def bar(a:fixnum)
447
+ # def bar(a:int)
522
448
  # loop do
523
449
  # a += 1
524
450
  # break if a > 2
@@ -530,7 +456,7 @@ class JVMCompilerTest < Test::Unit::TestCase
530
456
 
531
457
  loopy, = compile(<<-EOF)
532
458
  class Loopy
533
- def bar(a:fixnum)
459
+ def bar(a:int)
534
460
  loop do
535
461
  a += 1
536
462
  break if a > 2
@@ -701,7 +627,7 @@ class JVMCompilerTest < Test::Unit::TestCase
701
627
  def test_fields
702
628
  cls, = compile(<<-EOF)
703
629
  class FieldTest
704
- def initialize(a:fixnum)
630
+ def initialize(a:int)
705
631
  @a = a
706
632
  end
707
633
 
@@ -709,7 +635,7 @@ class JVMCompilerTest < Test::Unit::TestCase
709
635
  @a
710
636
  end
711
637
 
712
- def self.set_b(b:fixnum)
638
+ def self.set_b(b:int)
713
639
  @@b = b
714
640
  end
715
641
 
@@ -791,58 +717,52 @@ class JVMCompilerTest < Test::Unit::TestCase
791
717
  def _Double(a:double)
792
718
  a
793
719
  end
794
- EOF
720
+ EOF
795
721
 
796
- assert_equal(1.0, cls._Byte(1))
797
- assert_equal(127.0, cls._Byte(127))
798
- assert_equal(128.0, cls._Short(128))
799
- assert_equal(32767.0, cls._Short(32767))
800
- assert_equal(32768.0, cls._Int(32768))
801
- assert_equal(2147483648.0, cls._Long(2147483648))
722
+ assert_equal(1.0, cls._Byte(1))
723
+ assert_equal(127.0, cls._Byte(127))
724
+ assert_equal(128.0, cls._Short(128))
725
+ assert_equal(32767.0, cls._Short(32767))
726
+ assert_equal(32768.0, cls._Int(32768))
727
+ assert_equal(2147483648.0, cls._Long(2147483648))
802
728
  end
803
729
 
804
- def test_interface_declaration
805
- interface = compile('interface A; end').first
806
- assert(interface.java_class.interface?)
807
- assert_equal('A', interface.java_class.name)
808
-
809
- a, b = compile('interface A; end; interface B < A; end')
810
- assert_include(a, b.ancestors)
811
- assert_equal('A', a.java_class.name)
812
- assert_equal('B', b.java_class.name)
813
-
814
- a, b, c = compile(<<-EOF)
815
- interface A
730
+ def test_argument_boxing
731
+ [ [:short], [:int,:integer], [:long], [:byte]].each do |types|
732
+ primitive, full = types.first, types.last
733
+ begin
734
+ cls, = compile(<<-EOF)
735
+ def to_#{primitive}(a:#{full.to_s.capitalize}):void
736
+ puts a
737
+ end
738
+ to_#{primitive} #{primitive}(1)
739
+ EOF
740
+ assert_output("1\n") { cls.main nil}
741
+ rescue => e
742
+ raise "#{primitive} #{e.message}"
816
743
  end
817
-
818
- interface B
744
+ end
745
+ %w[float double].each do |type|
746
+ begin
747
+ cls, = compile(<<-EOF)
748
+ def to_#{type}(a:#{type.to_s.capitalize}):void
749
+ puts a
750
+ end
751
+ to_#{type} #{type}(1)
752
+ EOF
753
+ assert_output("1.0\n") { cls.main nil}
754
+ rescue => e
755
+ raise "#{type} #{e.message}"
819
756
  end
757
+ end
820
758
 
821
- interface C < A, B
759
+ cls, = compile(<<-EOF)
760
+ def to_character(a:Character):void
761
+ puts a
822
762
  end
763
+ to_character char(65)
823
764
  EOF
824
-
825
- assert_include(a, c.ancestors)
826
- assert_include(b, c.ancestors)
827
- assert_equal('A', a.java_class.name)
828
- assert_equal('B', b.java_class.name)
829
- assert_equal('C', c.java_class.name)
830
- end
831
-
832
- def test_interface_override_return_type
833
- assert_raise Mirah::MirahError do
834
- compile(<<-EOF)
835
- interface A
836
- def a:int; end
837
- end
838
-
839
- class Impl implements A
840
- def a
841
- "foo"
842
- end
843
- end
844
- EOF
845
- end
765
+ assert_output("A\n") { cls.main nil}
846
766
  end
847
767
 
848
768
  def test_raise
@@ -895,153 +815,6 @@ class JVMCompilerTest < Test::Unit::TestCase
895
815
  end
896
816
  end
897
817
 
898
- def test_ensure
899
- cls, = compile(<<-EOF)
900
- def foo
901
- 1
902
- ensure
903
- System.out.println "Hi"
904
- end
905
- EOF
906
- output = capture_output do
907
- assert_equal(1, cls.foo)
908
- end
909
- assert_equal "Hi\n", output
910
-
911
- cls, = compile(<<-EOF)
912
- def foo
913
- return 1
914
- ensure
915
- System.out.println "Hi"
916
- end
917
- EOF
918
- output = capture_output do
919
- assert_equal(1, cls.foo)
920
- end
921
- assert_equal "Hi\n", output
922
-
923
- cls, = compile(<<-EOF)
924
- def foo
925
- begin
926
- break
927
- ensure
928
- System.out.println "Hi"
929
- end while false
930
- end
931
- EOF
932
- output = capture_output do
933
- cls.foo
934
- end
935
- assert_equal "Hi\n", output
936
- end
937
-
938
- def test_cast
939
- cls, = compile(<<-EOF)
940
- def f2b; byte(1.0); end
941
- def f2s; short(1.0); end
942
- def f2c; char(1.0); end
943
- def f2i; int(1.0); end
944
- def f2l; long(1.0); end
945
- def f2d; int(1.0); end
946
-
947
- def i2b; byte(1); end
948
- def i2s; short(1); end
949
- def i2c; char(1); end
950
- def i2l; long(1); end
951
- def i2f; float(1); end
952
- def i2d; int(1); end
953
-
954
- def b2s; short(byte(1)); end
955
- def b2c; char(byte(1)); end
956
- def b2i; int(byte(1)); end
957
- def b2l; long(byte(1)); end
958
- def b2f; float(byte(1)); end
959
- def b2d; double(byte(1)); end
960
-
961
- def s2b; byte(short(1)); end
962
- def s2c; char(short(1)); end
963
- def s2i; int(short(1)); end
964
- def s2l; long(short(1)); end
965
- def s2f; float(short(1)); end
966
- def s2d; double(short(1)); end
967
-
968
- def c2b; byte(char(1)); end
969
- def c2s; short(char(1)); end
970
- def c2i; int(char(1)); end
971
- def c2l; long(char(1)); end
972
- def c2f; float(char(1)); end
973
- def c2d; double(char(1)); end
974
-
975
- def l2b; byte(long(1)); end
976
- def l2c; char(long(1)); end
977
- def l2i; int(long(1)); end
978
- def l2l; long(long(1)); end
979
- def l2f; float(long(1)); end
980
- def l2d; double(long(1)); end
981
-
982
- def d2b; byte(1.0); end
983
- def d2s; short(1.0); end
984
- def d2c; char(1.0); end
985
- def d2i; int(1.0); end
986
- def d2l; long(1.0); end
987
- def d2f; float(1.0); end
988
-
989
- def hard_i2f(a:int)
990
- float(if a < 0
991
- a *= -1
992
- a * 2
993
- else
994
- a * 2
995
- end)
996
- end
997
- EOF
998
-
999
- assert_equal 1, cls.b2s
1000
- assert_equal 1, cls.b2c
1001
- assert_equal 1, cls.b2i
1002
- assert_equal 1, cls.b2l
1003
- assert_equal 1.0, cls.b2f
1004
- assert_equal 1.0, cls.b2d
1005
-
1006
- assert_equal 1, cls.s2b
1007
- assert_equal 1, cls.s2c
1008
- assert_equal 1, cls.s2i
1009
- assert_equal 1, cls.s2l
1010
- assert_equal 1.0, cls.s2f
1011
- assert_equal 1.0, cls.s2d
1012
-
1013
- assert_equal 1, cls.c2b
1014
- assert_equal 1, cls.c2s
1015
- assert_equal 1, cls.c2i
1016
- assert_equal 1, cls.c2l
1017
- assert_equal 1.0, cls.c2f
1018
- assert_equal 1.0, cls.c2d
1019
-
1020
- assert_equal 1, cls.i2b
1021
- assert_equal 1, cls.i2s
1022
- assert_equal 1, cls.i2c
1023
- assert_equal 1, cls.i2l
1024
- assert_equal 1.0, cls.i2f
1025
- assert_equal 1.0, cls.i2d
1026
-
1027
- assert_equal 1, cls.f2b
1028
- assert_equal 1, cls.f2s
1029
- assert_equal 1, cls.f2c
1030
- assert_equal 1, cls.f2i
1031
- assert_equal 1, cls.f2l
1032
- assert_equal 1.0, cls.f2d
1033
-
1034
- assert_equal 1, cls.d2b
1035
- assert_equal 1, cls.d2s
1036
- assert_equal 1, cls.d2c
1037
- assert_equal 1, cls.d2i
1038
- assert_equal 1, cls.d2l
1039
- assert_equal 1.0, cls.d2f
1040
-
1041
- assert_equal 2.0, cls.hard_i2f(1)
1042
- assert_equal 4.0, cls.hard_i2f(-2)
1043
- end
1044
-
1045
818
  def test_set
1046
819
  cls, = compile(<<-EOF)
1047
820
  def foo
@@ -1440,7 +1213,7 @@ class JVMCompilerTest < Test::Unit::TestCase
1440
1213
 
1441
1214
  def test_super
1442
1215
  cls, = compile(<<-EOF)
1443
- class Foo
1216
+ class SuperEqual
1444
1217
  def equals(other:Object); super(other); end
1445
1218
  end
1446
1219
  EOF
@@ -1501,43 +1274,6 @@ class JVMCompilerTest < Test::Unit::TestCase
1501
1274
  cls.make_one(nil)
1502
1275
  end
1503
1276
 
1504
- def test_java_lang_cast
1505
- cls, = compile(<<-EOF)
1506
- def foo(a:Object)
1507
- Integer(a).intValue
1508
- end
1509
- EOF
1510
-
1511
- assert_equal(2, cls.foo(java.lang.Integer.new(2)))
1512
- end
1513
-
1514
- def test_array_cast
1515
- cls, = compile(<<-EOF)
1516
- def foo(a:Object)
1517
- bar(String[].cast(a))
1518
- end
1519
-
1520
- def bar(a:String[])
1521
- a[0]
1522
- end
1523
- EOF
1524
-
1525
- assert_equal("foo", cls.foo(["foo", "bar"].to_java(:string)))
1526
-
1527
- cls, = compile(<<-EOF)
1528
- def foo(a:Object)
1529
- bar(int[].cast(a))
1530
- end
1531
-
1532
- def bar(a:int[])
1533
- a[0]
1534
- end
1535
- EOF
1536
-
1537
- assert_equal(2, cls.foo([2, 3].to_java(:int)))
1538
-
1539
- end
1540
-
1541
1277
  def test_string_interpolation
1542
1278
  cls, = compile(<<-EOF)
1543
1279
  def foo(name:String)
@@ -1628,6 +1364,18 @@ class JVMCompilerTest < Test::Unit::TestCase
1628
1364
  assert_equal("java.lang.Character$UnicodeBlock", subset.java_class.name)
1629
1365
  end
1630
1366
 
1367
+ def test_lowercase_inner_class
1368
+ cls, = compile(<<-EOF)
1369
+ import org.foo.LowerCaseInnerClass
1370
+
1371
+ def foo
1372
+ LowerCaseInnerClass.inner.field
1373
+ end
1374
+ EOF
1375
+
1376
+ assert_equal(1234, cls.foo)
1377
+ end
1378
+
1631
1379
  def test_class_literal
1632
1380
  cls, = compile(<<-EOF)
1633
1381
  def foo
@@ -1649,35 +1397,6 @@ class JVMCompilerTest < Test::Unit::TestCase
1649
1397
  assert_equal(false, cls.string(2))
1650
1398
  end
1651
1399
 
1652
- def test_static_import
1653
- cls, = compile(<<-EOF)
1654
- import java.util.Arrays
1655
- include Arrays
1656
- def list(x:Object[])
1657
- asList(x)
1658
- end
1659
- EOF
1660
-
1661
- o = ["1", "2", "3"].to_java(:object)
1662
- list = cls.list(o)
1663
- assert_kind_of(Java::JavaUtil::List, list)
1664
- assert_equal(["1", "2", "3"], list.to_a)
1665
-
1666
- cls, = compile(<<-EOF)
1667
- import java.util.Arrays
1668
- class StaticImports
1669
- include Arrays
1670
- def list(x:Object[])
1671
- asList(x)
1672
- end
1673
- end
1674
- EOF
1675
-
1676
- list = cls.new.list(o)
1677
- assert_kind_of(Java::JavaUtil::List, list)
1678
- assert_equal(["1", "2", "3"], list.to_a)
1679
- end
1680
-
1681
1400
  # TODO: need a writable field somewhere...
1682
1401
  # def test_field_write
1683
1402
  # cls, = compile(<<-EOF)
@@ -1712,25 +1431,8 @@ class JVMCompilerTest < Test::Unit::TestCase
1712
1431
  assert_equal('Static Hello', output)
1713
1432
  end
1714
1433
 
1715
- def test_loop_in_ensure
1716
- cls, = compile(<<-EOF)
1717
- begin
1718
- System.out.println "a"
1719
- begin
1720
- System.out.println "b"
1721
- break
1722
- end while false
1723
- System.out.println "c"
1724
- ensure
1725
- System.out.println "ensure"
1726
- end
1727
- EOF
1728
-
1729
- assert_output("a\nb\nc\nensure\n") { cls.main(nil) }
1730
- end
1731
-
1732
1434
  def test_return_type
1733
- assert_raise Mirah::MirahError do
1435
+ assert_raise_kind_of Mirah::MirahError do
1734
1436
  compile(<<-EOF)
1735
1437
  class ReturnsA
1736
1438
  def a:int
@@ -1740,7 +1442,7 @@ class JVMCompilerTest < Test::Unit::TestCase
1740
1442
  EOF
1741
1443
  end
1742
1444
 
1743
- assert_raise Mirah::MirahError do
1445
+ assert_raise_kind_of Mirah::MirahError do
1744
1446
  compile(<<-EOF)
1745
1447
  class ReturnsB
1746
1448
  def self.a:String
@@ -1923,7 +1625,7 @@ class JVMCompilerTest < Test::Unit::TestCase
1923
1625
 
1924
1626
  cls, = compile(<<-EOF)
1925
1627
  a = nil
1926
- System.out.println a
1628
+ System.out.println Object(a)
1927
1629
  EOF
1928
1630
 
1929
1631
  assert_output("null\n") do
@@ -1960,7 +1662,7 @@ class JVMCompilerTest < Test::Unit::TestCase
1960
1662
  end
1961
1663
  end
1962
1664
 
1963
- def test_field_setter_wit_nil
1665
+ def test_field_setter_with_nil
1964
1666
  cls, = compile(<<-EOF)
1965
1667
  import mirah.lang.ast.*
1966
1668
  a = Arguments.new
@@ -1971,4 +1673,118 @@ class JVMCompilerTest < Test::Unit::TestCase
1971
1673
  assert_output("OK") { cls.main(nil) }
1972
1674
  end
1973
1675
 
1676
+ def test_assign_int_to_double
1677
+ cls, = compile(<<-EOF)
1678
+ def foo
1679
+ a = 1.0
1680
+ a = 0
1681
+ end
1682
+ EOF
1683
+
1684
+ assert_equal(0.0, cls.foo)
1685
+ end
1686
+
1687
+ def test_assign_int_to_double_with_additional_assign_is_int
1688
+ cls, = compile(<<-EOF)
1689
+ def foo
1690
+ a = 1.0
1691
+ b = a = 0
1692
+ end
1693
+ EOF
1694
+ assert(cls.foo.is_a? Fixnum)
1695
+ assert_equal(0, cls.foo)
1696
+ end
1697
+
1698
+ def test_assign_int_to_double_with_additional_assign_and_specified_return_as_double_is_double
1699
+ cls, = compile(<<-EOF)
1700
+ def foo : double
1701
+ a = 1.0
1702
+ b = a = 0
1703
+ end
1704
+ EOF
1705
+ assert(cls.foo.is_a? Float)
1706
+ assert_equal(0, cls.foo)
1707
+ end
1708
+
1709
+ def test_return_int_when_specified_return_as_double_is_double
1710
+ cls, = compile(<<-EOF)
1711
+ def foo : double
1712
+ 0
1713
+ end
1714
+ EOF
1715
+ assert(cls.foo.is_a? Float)
1716
+ assert_equal(0, cls.foo)
1717
+ end
1718
+
1719
+ def test_assign_int_to_double_in_closure
1720
+ cls, = compile(<<-EOF)
1721
+ def bar(r:Runnable); r.run; end
1722
+
1723
+ def foo
1724
+ a = 1.0
1725
+ bar do
1726
+ a = 0
1727
+ end
1728
+ a
1729
+ end
1730
+ EOF
1731
+
1732
+ assert_equal(0.0, cls.foo)
1733
+ end
1734
+
1735
+ def test_array_literals_are_modifiable
1736
+ cls, = compile(<<-EOF)
1737
+ def foo
1738
+ arr = [1,2]
1739
+ arr.add(3)
1740
+ arr[2]
1741
+ end
1742
+ EOF
1743
+
1744
+ assert_equal(3, cls.foo)
1745
+ end
1746
+
1747
+ def test_static_method_inheritance
1748
+ cls, = compile(<<-EOF)
1749
+ class Parent
1750
+ def self.my_method
1751
+ 'ran my method'
1752
+ end
1753
+ end
1754
+
1755
+ class Child < Parent
1756
+ end
1757
+
1758
+ puts Child.my_method
1759
+ EOF
1760
+
1761
+ assert_output "ran my method\n" do
1762
+ cls.main(nil)
1763
+ end
1764
+ end
1765
+
1766
+ def test_static_field_inheritance_lookup_with_dot
1767
+ cls, = compile(<<-EOF)
1768
+ import java.util.GregorianCalendar
1769
+ puts GregorianCalendar.AM
1770
+ EOF
1771
+
1772
+ assert_output "0\n" do
1773
+ cls.main(nil)
1774
+ end
1775
+ end
1776
+
1777
+ def test_static_field_inheritance_lookup_with_double_colon
1778
+ pend("double colon is treated special for lookup") {
1779
+ cls, = compile(<<-EOF)
1780
+ import java.util.GregorianCalendar
1781
+ puts GregorianCalendar::AM
1782
+ EOF
1783
+
1784
+ assert_output "0\n" do
1785
+ cls.main(nil)
1786
+ end
1787
+ }
1788
+ end
1789
+
1974
1790
  end