Package com.CompPad

Source Code of com.CompPad.quickTest

package com.CompPad;

import com.CompPad.model.operators.Operator;
import junit.framework.TestCase;
import com.CompPad.shell.Shell;
import groovy.lang.Closure;
import java.util.ArrayList;
import java.util.LinkedList;
/**
* Not exactly a unit test, but testing basic integrated functionality of
* computational model.
* @author trule
*/
public class quickTest extends TestCase{
    Shell testShell ;
    Object o;
    String setup[] = {           
        "m := METER",
        "rad := RADIAN",
            "i := sqrt{-1}",
            "a := 2",
            "aa := -5", /* Testing negative operator */
            "ax := 0.7",
            "b := 3 m",
            "b2 := 5 m",
            "bb := 4 rad",
            "c := 5 + 6 i",
            "d := (7 + 8 i) m",
            "d2 := (5 + 9 i ) m",
            "dd := (7 + 8 i) rad",
            "A:= matrix {1 # 2 ## 3 # 4 }",
            "B:= A m",
            "BB := A rad",
            "C := A c",
            "D := A d",
            "v := matrix {7 ## 8}",
            "vv := (9,10)" ,
            "v_2 := matrix{7 ## 8 ## 9 ## 10}",
            "v_3 := (7,8,9,10)",
            "j := false","k := true",
            "E1 := matrix {true # false ## false # true }",
            "E2 := matrix {false # false ## true # true }",
            "e1 := matrix {true ## false }",
    };
    public quickTest(String testName) throws Exception {
        super(testName);
    }

    @Override
    protected void setUp() throws Exception  {
        super.setUp();
        testShell = new Shell();
        o = testShell.evaluate(setup);
        if (Exception.class.isInstance(o)){
            fail(o.toString());
        }
       
      }

    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
    }

    /**
     * Test of main method, of class TestFormulas.
     */
    public void testTest() throws Exception{
        System.out.println("quickTest");
        /* Test error strings */
        String expressions[] = {
            "xyz" ,
            "1/0",
            "METER + SECOND",
            "A sub {1,2}",
            "v times vv^T",
            "A times v_2",
            "A / v_2",
            "v ^ 2",
            "2^METER",
            "m^0.26",
            "nroot{1.25}{2 m}",
            "plotxy(1,2 METER)", // args must be dimensionless
            "plotxy(1,2,3)", // argument must have even number of rows (x1,y1,x2,y2,...)
            "x + ",
            "(1))","(1",
            "sin(\"hello\")","sin(m)",
            "f(x):=x+1","g(f):=f(7)","g(2)"
        };
        for (String s:expressions){
            testShell.evaluate(s);
        }
//        o = testShell.evaluate(expressions);
//        if (Exception.class.isInstance(o)){
//            fail(o.toString());
//        }
    }
}
TOP

Related Classes of com.CompPad.quickTest

TOP
Copyright © 2018 www.massapi.com. 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.