forked from beanshell/beanshell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes beanshell#707 generated return types are reloaded Fixes beanshell#708 generated parameter types are reloaded Related to beanshell#659 improved scripted object detection, fixes is method bug
- Loading branch information
Showing
10 changed files
with
184 additions
and
20 deletions.
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
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
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
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,57 @@ | ||
#!/bin/java bsh.Interpreter | ||
|
||
source("TestHarness.bsh"); | ||
source("Assert.bsh"); | ||
|
||
// method return and parameter types reload | ||
|
||
// return type #707 | ||
class A {} | ||
A returnA(a) { | ||
return a; | ||
} | ||
a = new A(); | ||
b4 = a.getClass(); | ||
assertSame("Returns the same typed instance untyped parameter", a, returnA(a)); | ||
class A {} | ||
a = new A(); | ||
assertSame("Returns the same typed instance untyped parameter reloaded", a, returnA(a)); | ||
assertNotSame("A and A before is not the same", b4, a.getClass()); | ||
|
||
// parameter type #708 | ||
paramA(A a) { | ||
return a; | ||
} | ||
a = new A(); | ||
b4 = a.getClass(); | ||
assertSame("Returns the same untyped instance typed parameter", a, paramA(a)); | ||
class A {} | ||
a = new A(); | ||
assertSame("Returns the same untyped instance typed parameter reloaded", a, paramA(a)); | ||
assertNotSame("A and A before is not the same", b4, a.getClass()); | ||
|
||
// return and parameter type | ||
A returnParamA(A a) { | ||
return a; | ||
} | ||
a = new A(); | ||
b4 = a.getClass(); | ||
assertSame("Returns the same typed instance typed parameter", a, returnParamA(a)); | ||
class A {} | ||
a = new A(); | ||
assertSame("Returns the same typed instance typed parameter reloaded", a, returnParamA(a)); | ||
assertNotSame("A and A before is not the same", b4, a.getClass()); | ||
|
||
// non generated types | ||
Object objectA(final Object a) { | ||
return a; | ||
} | ||
a = new A(); | ||
b4 = a.getClass(); | ||
assertSame("Returns the same typed instance untyped parameter", a, objectA(a)); | ||
class A {} | ||
a = new A(); | ||
assertSame("Returns the same typed instance untyped parameter reloaded", a, objectA(a)); | ||
assertNotSame("A and A before is not the same", b4, a.getClass()); | ||
|
||
complete(); |
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,46 @@ | ||
#!/bin/java bsh.Interpreter | ||
|
||
source("TestHarness.bsh"); | ||
source("Assert.bsh"); | ||
|
||
/* | ||
* closure called from block with additional method does not break | ||
* Related to #659 | ||
*/ | ||
|
||
Object closure1() { | ||
list = new ArrayList(); | ||
this.list.add(1); | ||
|
||
return this; | ||
} | ||
|
||
double doesntMatter() { | ||
return 1; | ||
} | ||
|
||
try { | ||
t = closure1(); | ||
assertEquals("list size is equal te 1", 1, t.list.size()); | ||
} catch (Exception ex) { | ||
assert(false); | ||
} | ||
|
||
/* | ||
* sudo scripted object returning from this reported #659 | ||
*/ | ||
closure2() { | ||
list = new ArrayList(); | ||
this.list.add(1); | ||
|
||
return this.list; | ||
} | ||
|
||
assertEquals("has one element from global", 1, closure2().size()); | ||
{ assertEquals("has one element from block", 1, closure2().size()); } | ||
{ | ||
t = closure2(); | ||
assertEquals("has one element from block assigned", 1, t.size()); | ||
} | ||
|
||
complete(); |