Code Monkey home page Code Monkey logo

beanshell-quantum's People

Contributors

drosenbauer avatar jmetertea avatar mjwall avatar morris821028 avatar mreasy avatar nickl- avatar pgiffuni avatar smehrbrodt avatar stain avatar stefanofornari avatar

Watchers

 avatar  avatar

beanshell-quantum's Issues

Test Case for Super

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();
		}
	}

}

Test Case for Unicode

// \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");
	}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.