Package st.gravel.support.compiler.testtools

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


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

    Class classA = new ClassBuilder("ClassA_testSuperSend1")
        .method("sendSuper: bar ^bar + 1")
        .build();

    Class classB = new ClassBuilder("ClassB_testSuperSend1")
    .superclassName("ClassA_testSuperSend1")
    .method("sendSuper: bar ^(super sendSuper: bar) + 2")
    .build();

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


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

    Class classA = new ClassBuilder("ClassA_testSuperSend2")
        .method("sendSuper: bar ^bar + 1")
        .build();

    Class classB = new ClassBuilder("ClassB_testSuperSend2")
    .superclassName("ClassA_testSuperSend2")
    .build();
    Class classC = new ClassBuilder("ClassC_testSuperSend2")
    .superclassName("ClassB_testSuperSend2")
    .method("sendSuper: bar ^(super sendSuper: bar) + 2")
    .build();

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

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

    Class stClass = new ClassBuilder("FooObject_testBooleanAnd").method(
        "foo: a bar: b ^a and: [b]").build();

    Object fooObject = stClass.newInstance();
    Method method = fooObject.getClass().getMethod("foo_bar_", Object.class, Object.class);
    assertEquals(Boolean.TRUE, method.invoke(fooObject, true, true));
View Full Code Here

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

    Class stClass = new ClassBuilder("FooObject_testBooleanOr").method(
        "foo: a bar: b ^a or: [b]").build();

    Object fooObject = stClass.newInstance();
    Method method = fooObject.getClass().getMethod("foo_bar_", Object.class, Object.class);
    assertEquals(Boolean.TRUE, method.invoke(fooObject, true, true));
View Full Code Here

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

    Class stClass = new ClassBuilder("FooObject_testEmptyBlockReturnsNil").method(
        "foo ^[] value").build();

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

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

    Class stClass = new ClassBuilder("FooObject").method(
        "foo: bar\n" + "  | block |\n" + "  block := [:a | a + 4].\n"
            + "  ^block value: bar").build();

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

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

    Class stClass = new ClassBuilder("FooObject_testTwoArgCleanBlock").method(
        "foo: foo bar: bar\n" + "  | block |\n" + "  block := [:a :b| a + b].\n"
            + "  ^block value: foo value: bar").build();

    Object fooObject = stClass.newInstance();
    Method method = fooObject.getClass().getMethod("foo_bar_", Object.class, Object.class);
View Full Code Here

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

    Class stClass = new ClassBuilder("FooObject_testCopyingBlock")
        .method("foo: bar\n" + "  | block |\n"
            + "  block := [:a | a + bar].\n" + "  ^block value: 4")
        .build();

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

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

    Class stClass = new ClassBuilder(
        "FooObject_testCopyingBlockWithSelfReference")
        .method("foo ^11")
        .method("foo: bar\n" + "  | block |\n"
            + "  block := [:a | a + bar + self foo].\n"
            + "  ^block value: 4").build();
View Full Code Here

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

    Class stClass = new ClassBuilder("FooObject_testFullBlock")
        .method("foo: bar\n" + "  | block |\n" + "  block := [^1].\n"
            + "  bar ifFalse:  [block value].\n" + "  ^2").build();

    Object fooObject = stClass.newInstance();
    Method method = fooObject.getClass().getMethod("foo_", Object.class);
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.