Package st.gravel.support.compiler.testtools

Examples of st.gravel.support.compiler.testtools.ClassBuilder


  @Test
  public void testTemp() throws InstantiationException,
      IllegalAccessException, IllegalArgumentException,
      InvocationTargetException, NoSuchMethodException, SecurityException {
   
    Class stClass = new ClassBuilder("FooObject_testTemp").method("foo | a | a := 1. ^a")
        .build();

    Object fooObject = stClass.newInstance();
    Method method = fooObject.getClass().getMethod("foo");
    Object result = method.invoke(fooObject);
View Full Code Here


  @Test
  public void testFactorial() throws InstantiationException,
      IllegalAccessException, IllegalArgumentException,
      InvocationTargetException, NoSuchMethodException, SecurityException {

    Class stClass = new ClassBuilder("FooObject_testFactorial").method("foo ^100 factorial")
        .build();

    Object fooObject = stClass.newInstance();
    Method method = fooObject.getClass().getMethod("foo");
    Object result = null;
View Full Code Here

  @Test
  public void testReturnAssignment() throws InstantiationException,
      IllegalAccessException, IllegalArgumentException,
      InvocationTargetException, NoSuchMethodException, SecurityException {

    Class stClass = new ClassBuilder("FooObject_testReturnAssignment").method("foo | a | ^a := 3")
        .build();

    Object fooObject = stClass.newInstance();
    Method method = fooObject.getClass().getMethod("foo");
    Object result = method.invoke(fooObject);
View Full Code Here

  @Test
  public void testPlusInt() throws InstantiationException,
      IllegalAccessException, IllegalArgumentException,
      InvocationTargetException, NoSuchMethodException, SecurityException {

    Class stClass = new ClassBuilder("FooObject_testPlusInt").method(
        "foo ^3 + 4").build();

    Object fooObject = stClass.newInstance();
    Method method = fooObject.getClass().getMethod("foo");
    Object result = method.invoke(fooObject);
View Full Code Here

  @Test
  public void testPlusLargeInt() throws InstantiationException,
      IllegalAccessException, IllegalArgumentException,
      InvocationTargetException, NoSuchMethodException, SecurityException {

    Class stClass = new ClassBuilder("FooObject_testPlusLargeInt").method(
        "foo ^2147483647 + 1").build();
   
    Object fooObject = stClass.newInstance();
    Method method = fooObject.getClass().getMethod("foo");
    Object result = method.invoke(fooObject);
View Full Code Here

  @Test
  public void testSendMessage() throws InstantiationException,
      IllegalAccessException, IllegalArgumentException,
      InvocationTargetException, NoSuchMethodException, SecurityException {

    Class stClass = new ClassBuilder("FooObject_testSendMessage").
        method("foo ^1").
        method("bar ^self boo: self").
        method("boo: anObject ^anObject foo").
        build();
View Full Code Here

  @Test
  public void testDispatch() throws InstantiationException,
      IllegalAccessException, IllegalArgumentException,
      InvocationTargetException, NoSuchMethodException, SecurityException {

    Class constructor1 = new ClassBuilder("FooObject_testDispatch").
        method("boo: anObject ^anObject foo").
        build();

    Class constructor2 = new ClassBuilder("BorkObject_testDispatch").
        method("foo ^2").
        build();

    Object fooObject = constructor1.newInstance();
    Object borkObject = constructor2.newInstance();
View Full Code Here

  @Test
  public void testPolymorphicDispatch() throws InstantiationException,
      IllegalAccessException, IllegalArgumentException,
      InvocationTargetException, NoSuchMethodException, SecurityException {

    Class constructor1 = new ClassBuilder("FooObject_testPolymorphicDispatch").
        method("foo ^3").
        method("bar: anObject ^(self boo: self) + (self boo: anObject)").
        method("boo: anObject ^anObject foo").
        build();

    Class constructor2 = new ClassBuilder("BorkObject_testPolymorphicDispatch").
        method("foo ^4").
        build();


    Object fooObject = constructor1.newInstance();
View Full Code Here

  @Test
  public void testAssignTemp() throws InstantiationException,
      IllegalAccessException, IllegalArgumentException,
      InvocationTargetException, NoSuchMethodException, SecurityException {

    Class fooClass = new ClassBuilder("FooObject_testAssignTemp").
        method("foo: bar | a b |\n" +
            "  a := 3.\n" +
            "  b := a + bar.\n" +
            "  ^b").
        build();
View Full Code Here

  public void test_whileFalse() throws NoSuchMethodException,
      SecurityException, IllegalAccessException,
      IllegalArgumentException, InvocationTargetException,
      InstantiationException {

    Class stClass = new ClassBuilder("FooObject_test_whileFalse").method(
        "foo: sz | sum arr | arr := (1 to: sz) asArray.  sum := 0. [sum := sum + arr first.  arr := arr tail.  arr isEmpty] whileFalse.  ^sum").build();

    Object fooObject = stClass.newInstance();
    Method method = fooObject.getClass().getMethod("foo_", Object.class);
    assertEquals(Integer.valueOf(1), method.invoke(fooObject, 1));
View Full Code Here

TOP

Related Classes of st.gravel.support.compiler.testtools.ClassBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.