Package st.gravel.support.compiler.testtools

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


  }

  @Test
  public void test_ForkProcesses() throws Throwable {

    Class stClass = new ClassBuilder("FooObject_ForkProcesses").
        method("runForked: aName semaphore: sema " +
            "[1 to: 10 do: [:i |" +
            "Transcript cr; show: aName,': ', i printString. " +
            "(Delay forMilliseconds: 100) wait]. " +
            " sema signal] fork." +
View Full Code Here


  }

  @Test
  public void test_ParallelCollect() throws Throwable {

    Class stClass = new ClassBuilder("FooObject_ParallelCollect").
 
            method("parallelCollect" +
                "^(1 to: 1000) parallel: 20 collect: [:each |" +
                "| s | s := 0. " +
                "1 to: 100 do: [:i | 1 to: 100 do: [:j | s := s + (i * j)]]." +
View Full Code Here

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

    Class classA = new ClassBuilder("ClassA_testReflect")
        .method("reflect: anObject" +
            "  ^Reflection reflect: anObject")
        .method("className: anObject" +
            "  ^(self reflect: anObject) classMirror name")
        .method("metaclassName: anObject" +
View Full Code Here

  }

  @Test
  public void test_Integer_equals() throws Throwable {

    Class stClass = new ClassBuilder("FooObject_Integer_equals").
        method("foo: x equals: y ^x=y").
        method("foo ^self foo: 7 equals: 3+4").
        method("bar ^self foo: 7 equals: 1+2").
        build();
View Full Code Here

  }

  @Test
  public void test_Integer_identityEquals() throws Throwable {

    Class stClass = new ClassBuilder("FooObject_Integer_identityEquals").
        method("foo: x identityEquals: y ^x==y").
        method("foo ^self foo: 7 identityEquals: 3+4").
        method("bar ^self foo: 7 identityEquals: 1+2").
        build();
View Full Code Here

  }

  @Test
  public void test_Integer_notEquals() throws Throwable {

    Class stClass = new ClassBuilder("FooObject_Integer_notEquals").
        method("foo: x notEquals: y ^x~=y").
        method("foo ^self foo: 7 notEquals: 3+4").
        method("bar ^self foo: 7 notEquals: 1+2").
        build();
View Full Code Here

  }

  @Test
  public void test_Integer_notIdentityEquals() throws Throwable {

    Class stClass = new ClassBuilder("FooObject_Integer_notIdentityEquals").
        method("foo: x notIdentityEquals: y ^x~~y").
        method("foo ^self foo: 7 notIdentityEquals: 3+4").
        method("bar ^self foo: 7 notIdentityEquals: 1+2").
        build();
View Full Code Here

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

    Class stClass = new ClassBuilder("FooObject_testToDo")
        .method("foo ^self foo: 4")
        .method("foo: bar |t| t := 0. 1 to: bar do: [:i | t := t + i]. ^t")
        .build();

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

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

    Class stClass = new ClassBuilder("FooObject_testIfTrue1").method(
        "foo: bar bar ifTrue: [^1]. ^2").build();

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

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

    Class stClass = new ClassBuilder("FooObject_testIfTrue2").method(
        "foo: bar |t| t := 2. bar ifTrue:  [t := 1]. ^t").build();

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