forked from jruby/jruby
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add directory/framework for new java integration specs
Two specs to get things started git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@6509 961051c9-f516-0410-bf72-c9f7e237a7b7
- Loading branch information
1 parent
0248217
commit f020805
Showing
7 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
This sub-directory contains specs for JRuby's Java Integration features. | ||
|
||
== RUNNING | ||
|
||
Run the specs with "jruby -S rake jispec" from the root of the JRuby source tree. | ||
Specdoc will be printed to the console showing what has been implemented so far. | ||
|
||
== NOTES | ||
|
||
The work to create the specs is just starting; please follow these guidelines. | ||
|
||
- Keep the specs free of outside dependencies. | ||
- Create fixture Java classes in the fixtures/ subdirectory for use by the specs. | ||
Don't use any Java classes other than those in the fixtures directory, or in the | ||
JDK itself. | ||
- Create new *_spec.rb files in subdirectories grouped by functional area. Create new | ||
subdirectories if you need to. | ||
- For speed, the "jispec" task does not recompile the fixture classes. If you're | ||
adding new fixture classes, you will need to re-run the "test:compile" rake | ||
task in order to pick up the changes. |
5 changes: 5 additions & 0 deletions
5
test/spec/java_integration/fixtures/SingleMethodInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package spec.java_integration.fixtures; | ||
|
||
public interface SingleMethodInterface { | ||
Object callIt(); | ||
} |
10 changes: 10 additions & 0 deletions
10
test/spec/java_integration/fixtures/UsesSingleMethodInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package spec.java_integration.fixtures; | ||
|
||
public class UsesSingleMethodInterface { | ||
public static Object callIt(SingleMethodInterface obj) { | ||
return obj.callIt(); | ||
} | ||
public static Object castAndCallIt(Object obj) { | ||
return callIt((SingleMethodInterface) obj); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
test/spec/java_integration/interfaces/implementation_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require File.dirname(__FILE__) + "/../spec_helper" | ||
|
||
import "spec.java_integration.fixtures.SingleMethodInterface" | ||
import "spec.java_integration.fixtures.UsesSingleMethodInterface" | ||
|
||
describe "Single-method Java interfaces implemented in Ruby" do | ||
class ValueHolder | ||
include SingleMethodInterface | ||
def initialize(val) | ||
@value = val | ||
end | ||
def callIt | ||
@value | ||
end | ||
end | ||
|
||
it "should be implemented with 'include InterfaceClass'" do | ||
UsesSingleMethodInterface.callIt(ValueHolder.new(1)).should == 1 | ||
end | ||
|
||
it "should be cast-able to the interface on the Java side" do | ||
UsesSingleMethodInterface.castAndCallIt(ValueHolder.new(2)).should == 2 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--colour | ||
--format | ||
specdoc | ||
--loadby | ||
mtime | ||
--reverse | ||
--backtrace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'java' | ||
require File.dirname(__FILE__) + '/../../../build/jruby-test-classes.jar' | ||
require 'spec' | ||
|
||
Spec::Runner.configure do |config| | ||
# config.before :each do | ||
# end | ||
|
||
# config.after :each do | ||
# end | ||
end |