mirah 0.0.4-java → 0.0.5-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/History.txt +23 -0
  2. data/README.txt +13 -5
  3. data/Rakefile +30 -2
  4. data/bin/duby +16 -0
  5. data/bin/dubyc +16 -0
  6. data/bin/dubyp +16 -0
  7. data/bin/jrubyp +16 -0
  8. data/bin/mirah +17 -1
  9. data/bin/mirah.cmd +15 -0
  10. data/bin/mirahc +17 -1
  11. data/bin/mirahc.cmd +16 -1
  12. data/bin/mirahp +17 -1
  13. data/bin/mirahp.cmd +16 -1
  14. data/examples/appengine/Rakefile +17 -2
  15. data/examples/appengine/src/org/mirah/MirahApp.mirah +15 -0
  16. data/examples/bintrees.mirah +15 -0
  17. data/examples/construction.mirah +15 -0
  18. data/examples/dynamic.mirah +15 -0
  19. data/examples/edb.mirah +15 -0
  20. data/examples/fib.mirah +15 -0
  21. data/examples/fields.mirah +15 -0
  22. data/examples/fractal.mirah +15 -0
  23. data/examples/java_thing.mirah +15 -0
  24. data/examples/plugins/appengine/Rakefile +19 -4
  25. data/examples/plugins/appengine/lib/com/google/appengine/ext/duby/db/datastore.rb +21 -6
  26. data/examples/plugins/appengine/src/com/google/appengine/ext/duby/db/Model.duby +15 -0
  27. data/examples/plugins/appengine/test/com/google/appengine/ext/duby/db/ModelTest.duby +15 -0
  28. data/examples/simple_class.mirah +16 -1
  29. data/examples/sort_closure.mirah +15 -0
  30. data/examples/swing.mirah +17 -2
  31. data/examples/tak.mirah +15 -0
  32. data/examples/wiki/Rakefile +17 -2
  33. data/examples/wiki/src/org/mirah/wiki/MirahWiki.duby +15 -0
  34. data/examples/wiki/war/src/org/mirah/wiki/MirahWiki.duby +339 -0
  35. data/examples/wiki/war/src/org/mirah/wiki/edit.eduby.html +42 -0
  36. data/examples/wiki/war/src/org/mirah/wiki/error.eduby.html +2 -0
  37. data/examples/wiki/war/src/org/mirah/wiki/layout.eduby.html +69 -0
  38. data/examples/wiki/war/src/org/mirah/wiki/parser.eduby.html +7 -0
  39. data/examples/wiki/war/src/org/mirah/wiki/view.eduby.html +15 -0
  40. data/javalib/mirah-bootstrap.jar +0 -0
  41. data/javalib/mirah-parser.jar +0 -0
  42. data/lib/duby.rb +15 -0
  43. data/lib/mirah/appengine_tasks.rb +20 -6
  44. data/lib/mirah/ast/call.rb +19 -4
  45. data/lib/mirah/ast/class.rb +19 -4
  46. data/lib/mirah/ast/flow.rb +16 -1
  47. data/lib/mirah/ast/intrinsics.rb +36 -21
  48. data/lib/mirah/ast/literal.rb +16 -1
  49. data/lib/mirah/ast/local.rb +16 -1
  50. data/lib/mirah/ast/method.rb +18 -3
  51. data/lib/mirah/ast/scope.rb +19 -4
  52. data/lib/mirah/ast/structure.rb +16 -1
  53. data/lib/mirah/ast/type.rb +24 -9
  54. data/lib/mirah/ast.rb +24 -9
  55. data/lib/mirah/compiler.rb +16 -1
  56. data/lib/mirah/env.rb +16 -1
  57. data/lib/mirah/jvm/base.rb +18 -3
  58. data/lib/mirah/jvm/compiler.rb +35 -21
  59. data/lib/mirah/jvm/method_lookup.rb +16 -1
  60. data/lib/mirah/jvm/source_compiler.rb +29 -14
  61. data/lib/mirah/jvm/source_generator/builder.rb +21 -6
  62. data/lib/mirah/jvm/source_generator/loops.rb +16 -1
  63. data/lib/mirah/jvm/source_generator/precompile.rb +17 -2
  64. data/lib/mirah/jvm/source_generator/typer.rb +17 -2
  65. data/lib/mirah/jvm/typer.rb +19 -4
  66. data/lib/mirah/jvm/types/basic_types.rb +16 -1
  67. data/lib/mirah/jvm/types/boolean.rb +17 -2
  68. data/lib/mirah/jvm/types/enumerable.rb +21 -6
  69. data/lib/mirah/jvm/types/extensions.rb +16 -1
  70. data/lib/mirah/jvm/types/factory.rb +18 -3
  71. data/lib/mirah/jvm/types/floats.rb +16 -1
  72. data/lib/mirah/jvm/types/integers.rb +22 -7
  73. data/lib/mirah/jvm/types/intrinsics.rb +29 -14
  74. data/lib/mirah/jvm/types/literals.rb +16 -1
  75. data/lib/mirah/jvm/types/methods.rb +24 -9
  76. data/lib/mirah/jvm/types/number.rb +16 -1
  77. data/lib/mirah/jvm/types.rb +23 -4
  78. data/lib/mirah/nbcompiler.rb +19 -4
  79. data/lib/mirah/plugin/edb.rb +18 -3
  80. data/lib/mirah/plugin/gwt.rb +22 -7
  81. data/lib/mirah/plugin/java.rb +18 -3
  82. data/lib/mirah/transform.rb +35 -20
  83. data/lib/mirah/transform2.rb +20 -5
  84. data/lib/mirah/typer.rb +23 -8
  85. data/lib/mirah/version.rb +18 -0
  86. data/lib/mirah.rb +101 -50
  87. data/lib/mirah_task.rb +27 -12
  88. data/test/test_ast.rb +16 -1
  89. data/test/test_compilation.rb +18 -3
  90. data/test/test_env.rb +26 -11
  91. data/test/test_gwt.rb +18 -3
  92. data/test/test_java_typer.rb +27 -12
  93. data/test/test_javac_compiler.rb +17 -2
  94. data/test/test_jvm_compiler.rb +44 -14
  95. data/test/test_typer.rb +16 -1
  96. metadata +203 -193
data/lib/mirah_task.rb CHANGED
@@ -1,5 +1,20 @@
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
+
1
16
  require 'mirah'
2
- module Duby
17
+ module Mirah
3
18
  class PathArray < Array
4
19
  def <<(value)
5
20
  super(File.expand_path(value))
@@ -81,27 +96,27 @@ def mirahc(*files)
81
96
  else
82
97
  options = {}
83
98
  end
84
- source_dir = options.fetch(:dir, Duby.source_path)
85
- dest = File.expand_path(options.fetch(:dest, Duby.dest_path))
99
+ source_dir = options.fetch(:dir, Mirah.source_path)
100
+ dest = File.expand_path(options.fetch(:dest, Mirah.dest_path))
86
101
  files = files.map {|f| f.sub(/^#{source_dir}\//, '')}
87
- flags = options.fetch(:options, Duby.compiler_options)
102
+ flags = options.fetch(:options, Mirah.compiler_options)
88
103
  args = ['-d', dest, *flags] + files
89
104
  chdir(source_dir) do
90
105
  puts "mirahc #{args.join ' '}"
91
- Duby.compile(*args)
92
- Duby.reset
106
+ Mirah.compile(*args)
107
+ Mirah.reset
93
108
  end
94
109
  end
95
110
 
96
- rule '.java' => [proc {|n| Duby.dest_to_source_path(n)}] do |t|
111
+ rule '.java' => [proc {|n| Mirah.dest_to_source_path(n)}] do |t|
97
112
  mirahc(t.source,
98
- :dir=>Duby.find_source(t.source),
99
- :dest=>Duby.find_dest(t.name),
113
+ :dir=>Mirah.find_source(t.source),
114
+ :dest=>Mirah.find_dest(t.name),
100
115
  :options=>['-java'])
101
116
  end
102
117
 
103
- rule '.class' => [proc {|n| Duby.dest_to_source_path(n)}] do |t|
118
+ rule '.class' => [proc {|n| Mirah.dest_to_source_path(n)}] do |t|
104
119
  mirahc(t.source,
105
- :dir=>Duby.find_source(t.source),
106
- :dest=>Duby.find_dest(t.name))
120
+ :dir=>Mirah.find_source(t.source),
121
+ :dest=>Mirah.find_dest(t.name))
107
122
  end
data/test/test_ast.rb CHANGED
@@ -1,9 +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
+
1
16
  require 'mirah'
2
17
  require 'test/unit'
3
18
  require 'jruby'
4
19
 
5
20
  class TestAst < Test::Unit::TestCase
6
- include Duby
21
+ include Mirah
7
22
 
8
23
  def test_args
9
24
  new_ast = AST.parse("def foo(a, *c, &d); end").body[0]
@@ -1,10 +1,25 @@
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
+
1
16
  require 'mirah'
2
17
  require 'mirah/compiler'
3
18
  require 'test/unit'
4
19
  require 'jruby'
5
20
 
6
21
  class TestAst < Test::Unit::TestCase
7
- include Duby
22
+ include Mirah
8
23
 
9
24
  class MockCompiler
10
25
  attr_accessor :calls
@@ -81,7 +96,7 @@ class TestAst < Test::Unit::TestCase
81
96
 
82
97
  new_ast.compile(@compiler, true)
83
98
 
84
- assert_equal([[:local_assign, a(Duby::AST::StaticScope), "a", nil, true, AST.fixnum(nil, nil, 1)]], @compiler.calls)
99
+ assert_equal([[:local_assign, a(Mirah::AST::StaticScope), "a", nil, true, AST.fixnum(nil, nil, 1)]], @compiler.calls)
85
100
  end
86
101
 
87
102
  def test_local_typed
@@ -90,7 +105,7 @@ class TestAst < Test::Unit::TestCase
90
105
  new_ast.infer(typer)
91
106
  new_ast.compile(@compiler, true)
92
107
 
93
- assert_equal([[:local_assign, a(Duby::AST::StaticScope), "a", AST.type(nil, :fixnum), true, AST.fixnum(nil, nil, 1)]], @compiler.calls)
108
+ assert_equal([[:local_assign, a(Mirah::AST::StaticScope), "a", AST.type(nil, :fixnum), true, AST.fixnum(nil, nil, 1)]], @compiler.calls)
94
109
  end
95
110
 
96
111
  def test_return
data/test/test_env.rb CHANGED
@@ -1,42 +1,57 @@
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
+
1
16
  require 'test/unit'
2
17
  require 'mirah'
3
18
 
4
19
  class TestEnv < Test::Unit::TestCase
5
- include Duby
20
+ include Mirah
6
21
 
7
22
  def test_path_seperator
8
23
  # Check that env var PATH_SEPERATOR is used
9
24
  RbConfig::CONFIG['PATH_SEPARATOR'] = '*'
10
- assert_equal('*', Duby::Env.path_seperator)
25
+ assert_equal('*', Mirah::Env.path_seperator)
11
26
 
12
27
  # Check that : (colon) is returned if no PATH_SEPERATOR env var set
13
28
  RbConfig::CONFIG['PATH_SEPARATOR'] = ''
14
- assert_equal(':', Duby::Env.path_seperator)
29
+ assert_equal(':', Mirah::Env.path_seperator)
15
30
  end
16
31
 
17
32
  def test_encode_paths
18
33
  RbConfig::CONFIG['PATH_SEPARATOR'] = ':'
19
34
 
20
- assert_equal('a:b:c', Duby::Env.encode_paths(['a','b','c']))
21
- assert_equal('a', Duby::Env.encode_paths(['a']))
22
- assert_equal('', Duby::Env.encode_paths([]))
35
+ assert_equal('a:b:c', Mirah::Env.encode_paths(['a','b','c']))
36
+ assert_equal('a', Mirah::Env.encode_paths(['a']))
37
+ assert_equal('', Mirah::Env.encode_paths([]))
23
38
 
24
39
  RbConfig::CONFIG['PATH_SEPARATOR'] = ';'
25
40
 
26
- assert_equal('a;b;c', Duby::Env.encode_paths(['a','b','c']))
41
+ assert_equal('a;b;c', Mirah::Env.encode_paths(['a','b','c']))
27
42
  end
28
43
 
29
44
  def test_decode_paths
30
45
  RbConfig::CONFIG['PATH_SEPARATOR'] = ':'
31
46
 
32
47
  path_array = ['1','2']
33
- assert_equal(['1','2','a','b','c','d'], Duby::Env.decode_paths('a:b:c:d', path_array))
48
+ assert_equal(['1','2','a','b','c','d'], Mirah::Env.decode_paths('a:b:c:d', path_array))
34
49
  assert_equal(['1','2','a','b','c','d'], path_array)
35
50
 
36
- assert_equal(['a','b','c','d'], Duby::Env.decode_paths('a:b:c:d'))
37
- assert_equal(['a'], Duby::Env.decode_paths('a'))
51
+ assert_equal(['a','b','c','d'], Mirah::Env.decode_paths('a:b:c:d'))
52
+ assert_equal(['a'], Mirah::Env.decode_paths('a'))
38
53
 
39
54
  RbConfig::CONFIG['PATH_SEPARATOR'] = ';'
40
- assert_equal(['a','b','c','d'], Duby::Env.decode_paths('a;b;c;d'))
55
+ assert_equal(['a','b','c','d'], Mirah::Env.decode_paths('a;b;c;d'))
41
56
  end
42
57
  end
data/test/test_gwt.rb CHANGED
@@ -1,3 +1,18 @@
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
+
1
16
  $:.unshift File.join(File.dirname(__FILE__),'..','lib')
2
17
 
3
18
  require 'test/unit'
@@ -5,7 +20,7 @@ require 'mirah'
5
20
  require 'jruby'
6
21
 
7
22
  class TestGWT < Test::Unit::TestCase
8
- include Duby::AST
23
+ include Mirah::AST
9
24
 
10
25
  def test_jsni_static
11
26
  new_ast = parse("def_jsni void, _log(), 'hi'").body[0]
@@ -33,7 +48,7 @@ class TestGWT < Test::Unit::TestCase
33
48
  assert_equal(body, 'hi')
34
49
 
35
50
  signature = new_ast.signature
36
- return_type = signature[:return] == Duby::AST::TypeReference.new('void')
51
+ return_type = signature[:return] == Mirah::AST::TypeReference.new('void')
37
52
  assert_equal(return_type, true)
38
53
 
39
54
  has_arguments = new_ast.arguments.args
@@ -43,7 +58,7 @@ class TestGWT < Test::Unit::TestCase
43
58
  def test_jsni_one_arg
44
59
  new_ast = parse("def_jsni void, _log(message:Object), 'hi'").body[0]
45
60
 
46
- message_type = new_ast.signature[:message] == Duby::AST::TypeReference.new('Object')
61
+ message_type = new_ast.signature[:message] == Mirah::AST::TypeReference.new('Object')
47
62
  assert_equal(message_type, true)
48
63
 
49
64
  arg_size = new_ast.arguments.args.size
@@ -1,3 +1,18 @@
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
+
1
16
  $:.unshift File.join(File.dirname(__FILE__),'..','lib')
2
17
 
3
18
  require 'test/unit'
@@ -7,12 +22,12 @@ require 'mirah/jvm/compiler'
7
22
  require 'mirah/jvm/typer'
8
23
 
9
24
  class TestJavaTyper < Test::Unit::TestCase
10
- include Duby
25
+ include Mirah
11
26
 
12
27
  def setup
13
- AST.type_factory = Duby::JVM::Types::TypeFactory.new
28
+ AST.type_factory = Mirah::JVM::Types::TypeFactory.new
14
29
  @typer = Typer::JVM.new(nil)
15
- compiler = Duby::Compiler::JVM.new
30
+ compiler = Mirah::Compiler::JVM.new
16
31
 
17
32
  @java_typer = Typer::JavaTyper.new
18
33
  end
@@ -77,7 +92,7 @@ class TestJavaTyper < Test::Unit::TestCase
77
92
  end
78
93
  end
79
94
 
80
- include Duby::JVM::MethodLookup
95
+ include Mirah::JVM::MethodLookup
81
96
 
82
97
  def test_is_more_specific
83
98
  object = java.lang.Object.java_class
@@ -90,14 +105,14 @@ class TestJavaTyper < Test::Unit::TestCase
90
105
  end
91
106
 
92
107
  def test_primitive_convertible
93
- boolean = Duby::JVM::Types::Boolean
94
- byte = Duby::JVM::Types::Byte
95
- short = Duby::JVM::Types::Short
96
- char = Duby::JVM::Types::Char
97
- int = Duby::JVM::Types::Int
98
- long = Duby::JVM::Types::Long
99
- float = Duby::JVM::Types::Float
100
- double = Duby::JVM::Types::Double
108
+ boolean = Mirah::JVM::Types::Boolean
109
+ byte = Mirah::JVM::Types::Byte
110
+ short = Mirah::JVM::Types::Short
111
+ char = Mirah::JVM::Types::Char
112
+ int = Mirah::JVM::Types::Int
113
+ long = Mirah::JVM::Types::Long
114
+ float = Mirah::JVM::Types::Float
115
+ double = Mirah::JVM::Types::Double
101
116
 
102
117
  assert !primitive_convertible?(boolean, byte)
103
118
  assert !primitive_convertible?(boolean, short)
@@ -1,3 +1,18 @@
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
+
1
16
  $:.unshift File.join(File.dirname(__FILE__),'..','lib')
2
17
 
3
18
  require 'test/unit'
@@ -39,8 +54,8 @@ class TestJavacCompiler < TestJVMCompiler
39
54
  def compile(code)
40
55
  File.unlink(*@tmp_classes)
41
56
  @tmp_classes.clear
42
- AST.type_factory = Duby::JVM::Types::TypeFactory.new
43
- transformer = Duby::Transform::Transformer.new(Duby::CompilationState.new)
57
+ AST.type_factory = Mirah::JVM::Types::TypeFactory.new
58
+ transformer = Mirah::Transform::Transformer.new(Mirah::CompilationState.new)
44
59
  Java::MirahImpl::Builtin.initialize_builtins(transformer)
45
60
  name = "script" + System.nano_time.to_s
46
61
  ast = AST.parse(code, name, true, transformer)
@@ -1,3 +1,18 @@
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
+
1
16
  $:.unshift File.join(File.dirname(__FILE__),'..','lib')
2
17
 
3
18
  require 'test/unit'
@@ -6,13 +21,13 @@ require 'jruby'
6
21
  require 'stringio'
7
22
  require 'fileutils'
8
23
 
9
- unless Duby::AST.macro "__gloop__"
10
- Duby::AST.defmacro "__gloop__" do |transformer, fcall, parent|
11
- Duby::AST::Loop.new(parent, parent.position, true, false) do |loop|
24
+ unless Mirah::AST.macro "__gloop__"
25
+ Mirah::AST.defmacro "__gloop__" do |transformer, fcall, parent|
26
+ Mirah::AST::Loop.new(parent, parent.position, true, false) do |loop|
12
27
  init, condition, check_first, pre, post = fcall.parameters
13
28
  loop.check_first = check_first.literal
14
29
 
15
- nil_t = Duby::AST::Null
30
+ nil_t = Mirah::AST::Null
16
31
  loop.init = init
17
32
  loop.pre = pre
18
33
  loop.post = post
@@ -20,7 +35,7 @@ unless Duby::AST.macro "__gloop__"
20
35
  body = fcall.block.body
21
36
  body.parent = loop
22
37
  [
23
- Duby::AST::Condition.new(loop, parent.position) do |c|
38
+ Mirah::AST::Condition.new(loop, parent.position) do |c|
24
39
  condition.parent = c
25
40
  [condition]
26
41
  end,
@@ -31,7 +46,7 @@ unless Duby::AST.macro "__gloop__"
31
46
  end
32
47
 
33
48
  class TestJVMCompiler < Test::Unit::TestCase
34
- include Duby
49
+ include Mirah
35
50
  import java.lang.System
36
51
  import java.io.PrintStream
37
52
 
@@ -54,9 +69,9 @@ class TestJVMCompiler < Test::Unit::TestCase
54
69
  def compile(code)
55
70
  File.unlink(*@tmp_classes)
56
71
  @tmp_classes.clear
57
- AST.type_factory = Duby::JVM::Types::TypeFactory.new
72
+ AST.type_factory = Mirah::JVM::Types::TypeFactory.new
58
73
  name = "script" + System.nano_time.to_s
59
- transformer = Duby::Transform::Transformer.new(Duby::CompilationState.new)
74
+ transformer = Mirah::Transform::Transformer.new(Mirah::CompilationState.new)
60
75
  Java::MirahImpl::Builtin.initialize_builtins(transformer)
61
76
  ast = AST.parse(code, name, true, transformer)
62
77
  typer = Typer::JVM.new(transformer)
@@ -65,7 +80,7 @@ class TestJVMCompiler < Test::Unit::TestCase
65
80
  compiler = Compiler::JVM.new
66
81
  compiler.compile(ast)
67
82
  classes = {}
68
- loader = DubyClassLoader.new(JRuby.runtime.jruby_class_loader, classes)
83
+ loader = MirahClassLoader.new(JRuby.runtime.jruby_class_loader, classes)
69
84
  compiler.generate do |name, builder|
70
85
  bytes = builder.generate
71
86
  FileUtils.mkdir_p(File.dirname(name))
@@ -787,6 +802,14 @@ class TestJVMCompiler < Test::Unit::TestCase
787
802
  def a
788
803
  @a
789
804
  end
805
+
806
+ def self.set_b(b:fixnum)
807
+ @@b = b
808
+ end
809
+
810
+ def b
811
+ @@b
812
+ end
790
813
  end
791
814
  EOF
792
815
  first = cls.new(1)
@@ -795,6 +818,13 @@ class TestJVMCompiler < Test::Unit::TestCase
795
818
  second = cls.new(2)
796
819
  assert_equal(1, first.a)
797
820
  assert_equal(2, second.a)
821
+
822
+ cls.set_b 0
823
+ assert_equal(0, first.b)
824
+ assert_equal(0, second.b)
825
+ assert_equal(1, cls.set_b(1))
826
+ assert_equal(1, first.b)
827
+ assert_equal(1, second.b)
798
828
  end
799
829
 
800
830
  def test_object_intrinsics
@@ -894,7 +924,7 @@ class TestJVMCompiler < Test::Unit::TestCase
894
924
  assert_equal('B', b.java_class.name)
895
925
  assert_equal('C', c.java_class.name)
896
926
 
897
- assert_raise Duby::Typer::InferenceError do
927
+ assert_raise Mirah::Typer::InferenceError do
898
928
  compile(<<-EOF)
899
929
  interface A do
900
930
  def a
@@ -911,12 +941,12 @@ class TestJVMCompiler < Test::Unit::TestCase
911
941
  end
912
942
  end
913
943
 
914
- def assert_throw(type, message=nil)
944
+ def assert_throw(type, message="")
915
945
  ex = assert_raise(NativeException) do
916
946
  yield
917
947
  end
918
948
  assert_equal type, ex.cause.class
919
- assert_equal message, ex.cause.message
949
+ assert_equal message, ex.cause.message.to_s
920
950
  end
921
951
 
922
952
  def test_raise
@@ -2489,7 +2519,7 @@ class TestJVMCompiler < Test::Unit::TestCase
2489
2519
  end
2490
2520
 
2491
2521
  def test_return_type
2492
- assert_raise Duby::Typer::InferenceError do
2522
+ assert_raise Mirah::Typer::InferenceError do
2493
2523
  compile(<<-EOF)
2494
2524
  class ReturnsA
2495
2525
  def a:int
@@ -2499,7 +2529,7 @@ class TestJVMCompiler < Test::Unit::TestCase
2499
2529
  EOF
2500
2530
  end
2501
2531
 
2502
- assert_raise Duby::Typer::InferenceError do
2532
+ assert_raise Mirah::Typer::InferenceError do
2503
2533
  compile(<<-EOF)
2504
2534
  class ReturnsB
2505
2535
  def self.a:String
data/test/test_typer.rb CHANGED
@@ -1,8 +1,23 @@
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
+
1
16
  require 'test/unit'
2
17
  require 'mirah'
3
18
 
4
19
  class TestTyper < Test::Unit::TestCase
5
- include Duby
20
+ include Mirah
6
21
 
7
22
  def test_fixnum
8
23
  ast = AST.parse("1")