morris821028 / beanshell-quantum Goto Github PK
View Code? Open in Web Editor NEWThis project forked from beanshell/beanshell
Beanshell scripting language. See quantum branch
License: Apache License 2.0
This project forked from beanshell/beanshell
Beanshell scripting language. See quantum branch
License: Apache License 2.0
package bsh;
public class SuperMethod {
public static class Parent {
public boolean sayHi() {
System.err.println("HiHi");
return true;
}
}
public static class Child extends Parent {
public Child() {
}
public boolean sayNo() {
return true;
}
}
public static Child getChild() {
return new Child();
}
public static void test() throws EvalError {
final Interpreter interpreter = new Interpreter();
interpreter.eval(String.format("import %s;", SuperMethod.class.getName()));
Object result = interpreter.eval(String.format("cc = SuperMethod.getChild();"));
result = interpreter.eval(String.format("cc.sayHi();"));
assert (Boolean) result == true;
}
public static void test2() throws EvalError {
final Interpreter interpreter = new Interpreter();
interpreter.eval(String.format("import %s;", SuperMethod.class.getName()));
Child cc = new SuperMethod.Child();
Object result = interpreter.eval(String.format("cc = new SuperMethod.Child();"));
System.err.println(result);
result = interpreter.eval(String.format("cc.sayHi();"));
assert (Boolean) result == cc.sayHi();
}
public static void main(String[] args) {
try {
test2();
} catch (EvalError e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
// \unicorn
System.out.println("Morrisy");
@Test
public void parse_unicode_literals_in_comment() throws Exception {
final Interpreter interpreter = new Interpreter();
Object result = interpreter.eval("// source path: C:\\user\\desktop");
Assert.assertEquals(result, null);
}
@Test
public void parse_unicode_literals_in_apostrophe() throws Exception {
final Interpreter interpreter = new Interpreter();
char c = (char) interpreter.eval("return '\\u51ea\'");
Assert.assertEquals(c, '\u51ea');
}
@Test
public void parse_unicode_literals_in_quotes_and_comment() throws Exception {
final Interpreter interpreter = new Interpreter();
interpreter.eval("s = \"\\u51ea1234\"; // source path: C:\\user\\desktop");
String s = (String) interpreter.eval("s = s + \"\\u51EA3456\"");
Assert.assertEquals(s, "\u51ea1234\u51EA3456");
}
@Test
public void parse_unicode_literals_return_quotes_and_comment() throws Exception {
final Interpreter interpreter = new Interpreter();
String s = (String) interpreter.eval("return \"\\u51EA1234\"; // source path: C:\\user\\desktop");
Assert.assertEquals(s, "\u51EA1234");
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.