Package org.jatha.dynatype

Examples of org.jatha.dynatype.LispValue


        // (17 'z)
        // (17 'z :c "ojsan sa")
        // (17 'z :c "ojsan sa" :d 42)
        // (17 'z :d 42 :c "ojsan sa")

        final LispValue arg1 = lisp.makeInteger(17);
        final LispValue arg2 = lisp.EVAL.intern("z");
        final LispValue arg3 = lisp.makeString("ojsan sa");
        final LispValue arg4 = lisp.makeInteger(42);

        final LispValue argList1 = lisp.makeList(arg1);
        final LispValue argList2 = lisp.makeList(arg1,arg2);
        final LispValue argList3 = lisp.makeList(arg1,arg2,c_key,arg3);
        final LispValue argList4 = lisp.makeList(arg1,arg2,c_key,arg3).append(lisp.makeList(d_key,arg4));
        final LispValue argList5 = lisp.makeList(arg1,arg2,d_key,arg4).append(lisp.makeList(c_key,arg3));

        final Map outp1 = list6.parse(argList1);
        final Map outp2 = list6.parse(argList2);
        final Map outp3 = list6.parse(argList3);
        final Map outp4 = list6.parse(argList4);
        final Map outp5 = list6.parse(argList5);

        final LispValue expected3 = lisp.makeList(c_key,arg3);
        final LispValue expected4 = lisp.makeList(c_key,arg3,d_key,arg4);
        final LispValue expected5 = lisp.makeList(d_key,arg4,c_key,arg3);

        assertEquals("Argument 1 should be correct",arg1,outp1.get(a_sym));
        assertEquals("Argument 2 should be correct",list6_b_default,outp1.get(b_sym));
        assertEquals("Argument x should be correct",lisp.NIL,outp1.get(x_sym));
        assertEquals("Argument c should be correct",lisp.NIL,outp1.get(c_sym));
        assertEquals("Argument d should be correct",arg1,outp1.get(d_sym));

        assertEquals("Argument 1 should be correct",arg1,outp2.get(a_sym));
        assertEquals("Argument 2 should be correct",arg2,outp2.get(b_sym));
        assertEquals("Argument x should be correct",lisp.NIL,outp2.get(x_sym));
        assertEquals("Argument c should be correct",lisp.NIL,outp2.get(c_sym));
        assertEquals("Argument d should be correct",arg1,outp2.get(d_sym));

        assertEquals("Argument 1 should be correct",arg1,outp3.get(a_sym));
        assertEquals("Argument 2 should be correct",arg2,outp3.get(b_sym));
        assertTrue("Argument x should be correct",expected3.equal((LispValue)outp3.get(x_sym)) == lisp.T);
        assertEquals("Argument c should be correct",arg3,outp3.get(c_sym));
        assertEquals("Argument d should be correct",arg1,outp3.get(d_sym));

        assertEquals("Argument 1 should be correct",arg1,outp4.get(a_sym));
        assertEquals("Argument 2 should be correct",arg2,outp4.get(b_sym));
        assertTrue("Argument x should be correct",expected4.equal((LispValue)outp4.get(x_sym)) == lisp.T);
        assertEquals("Argument c should be correct",arg3,outp4.get(c_sym));
        assertEquals("Argument d should be correct",arg4,outp4.get(d_sym));

        assertEquals("Argument 1 should be correct",arg1,outp5.get(a_sym));
        assertEquals("Argument 2 should be correct",arg2,outp5.get(b_sym));
        assertTrue("Argument x should be correct",expected5.equal((LispValue)outp5.get(x_sym)) == lisp.T);
        assertEquals("Argument c should be correct",arg3,outp5.get(c_sym));
        assertEquals("Argument d should be correct",arg4,outp5.get(d_sym));
    }
View Full Code Here


        // (17 'z :c "ojsan sa")
        // (17 'z :c "ojsan sa" :d 42)
        // (17 'z :d 42 :c "ojsan sa")
        // (17 'z :d 42 :c "ojsan sa" :testing t)

        final LispValue arg1 = lisp.makeInteger(17);
        final LispValue arg2 = lisp.EVAL.intern("z");
        final LispValue arg3 = lisp.makeString("ojsan sa");
        final LispValue arg4 = lisp.makeInteger(42);
        final LispValue testing_key = lisp.EVAL.intern(":TESTING");

        final LispValue argList1 = lisp.makeList(arg1);
        final LispValue argList2 = lisp.makeList(arg1,arg2);
        final LispValue argList3 = lisp.makeList(arg1,arg2,c_key,arg3);
        final LispValue argList4 = lisp.makeList(arg1,arg2,c_key,arg3).append(lisp.makeList(d_key,arg4));
        final LispValue argList5 = lisp.makeList(arg1,arg2,d_key,arg4).append(lisp.makeList(c_key,arg3));
        final LispValue argList6 = lisp.makeList(arg1,arg2,d_key,arg4).append(lisp.makeList(c_key,arg3,testing_key,lisp.T));

        final Map outp1 = list7.parse(argList1);
        final Map outp2 = list7.parse(argList2);
        final Map outp3 = list7.parse(argList3);
        final Map outp4 = list7.parse(argList4);
        final Map outp5 = list7.parse(argList5);
        final Map outp6 = list7.parse(argList6);

        final LispValue expected3 = lisp.makeList(c_key,arg3);
        final LispValue expected4 = lisp.makeList(c_key,arg3,d_key,arg4);
        final LispValue expected5 = lisp.makeList(d_key,arg4,c_key,arg3);
        final LispValue expected6 = lisp.makeList(d_key,arg4,c_key,arg3).append(lisp.makeList(testing_key,lisp.T));

        assertEquals("Argument 1 should be correct",arg1,outp1.get(a_sym));
        assertEquals("Argument 2 should be correct",list7_b_default,outp1.get(b_sym));
        assertEquals("Argument x should be correct",lisp.NIL,outp1.get(x_sym));
        assertEquals("Argument c should be correct",lisp.NIL,outp1.get(c_sym));
        assertEquals("Argument d should be correct",arg1,outp1.get(d_sym));

        assertEquals("Argument 1 should be correct",arg1,outp2.get(a_sym));
        assertEquals("Argument 2 should be correct",arg2,outp2.get(b_sym));
        assertEquals("Argument x should be correct",lisp.NIL,outp2.get(x_sym));
        assertEquals("Argument c should be correct",lisp.NIL,outp2.get(c_sym));
        assertEquals("Argument d should be correct",arg1,outp2.get(d_sym));

        assertEquals("Argument 1 should be correct",arg1,outp3.get(a_sym));
        assertEquals("Argument 2 should be correct",arg2,outp3.get(b_sym));
        assertTrue("Argument x should be correct",expected3.equal((LispValue)outp3.get(x_sym)) == lisp.T);
        assertEquals("Argument c should be correct",arg3,outp3.get(c_sym));
        assertEquals("Argument d should be correct",arg1,outp3.get(d_sym));

        assertEquals("Argument 1 should be correct",arg1,outp4.get(a_sym));
        assertEquals("Argument 2 should be correct",arg2,outp4.get(b_sym));
        assertTrue("Argument x should be correct",expected4.equal((LispValue)outp4.get(x_sym)) == lisp.T);
        assertEquals("Argument c should be correct",arg3,outp4.get(c_sym));
        assertEquals("Argument d should be correct",arg4,outp4.get(d_sym));

        assertEquals("Argument 1 should be correct",arg1,outp5.get(a_sym));
        assertEquals("Argument 2 should be correct",arg2,outp5.get(b_sym));
        assertTrue("Argument x should be correct",expected5.equal((LispValue)outp5.get(x_sym)) == lisp.T);
        assertEquals("Argument c should be correct",arg3,outp5.get(c_sym));
        assertEquals("Argument d should be correct",arg4,outp5.get(d_sym));

        assertEquals("Argument 1 should be correct",arg1,outp6.get(a_sym));
        assertEquals("Argument 2 should be correct",arg2,outp6.get(b_sym));
        assertTrue("Argument x should be correct",expected6.equal((LispValue)outp6.get(x_sym)) == lisp.T);
        assertEquals("Argument c should be correct",arg3,outp6.get(c_sym));
        assertEquals("Argument d should be correct",arg4,outp6.get(d_sym));
    }
View Full Code Here

        // (a &key ((:c int) 13 supp))
        // arguments to test:
        // (17)
        // (17 :c 'z)
        // (17 :c 13)
        final LispValue arg1 = lisp.makeInteger(17);
        final LispValue arg2 = lisp.EVAL.intern("z");

        final LispValue argList1 = lisp.makeList(arg1);
        final LispValue argList2 = lisp.makeList(arg1,c_key,arg2);
        final LispValue argList3 = lisp.makeList(arg1,c_key,list8_c_default);

        final Map outp1 = list8.parse(argList1);
        final Map outp2 = list8.parse(argList2);
        final Map outp3 = list8.parse(argList3);
View Full Code Here

    public void testSupplyAllowOtherKeys() {
        // (a &key ((:c int) 13 supp))
        // arguments to test:
        // (17 :c 3 :allow-other-keys t :start 14)
        // (17 :c 3 :start 14 :allow-other-keys t)
        final LispValue arg1 = lisp.makeInteger(17);
        final LispValue arg2 = lisp.makeInteger(3);
        final LispValue all_ = lisp.EVAL.intern(":ALLOW-OTHER-KEYS");
        final LispValue start_ = lisp.EVAL.intern(":START");
        final LispValue start_arg = lisp.makeInteger(14);

        final LispValue argList1 = lisp.makeList(arg1,c_key,arg2,all_).append(lisp.makeList(lisp.T,start_,start_arg));
        final LispValue argList2 = lisp.makeList(arg1,c_key,arg2,start_).append(lisp.makeList(start_arg,all_,lisp.T));

        final Map outp1 = list8.parse(argList1);
        final Map outp2 = list8.parse(argList2);

        assertEquals("Argument 1 should be correct",arg1,outp1.get(a_sym));
View Full Code Here

    super(lisp, "STRING-EQUAL", 2);
  }

  public void Execute(SECDMachine machine)
  {
    LispValue arg2 = machine.S.pop();
    LispValue arg1 = machine.S.pop();

    machine.S.push(arg1.stringEqual(arg2));
    machine.C.pop();
  }
View Full Code Here

  }


  public LispValue intern(LispString symbolString, LispPackage pkg)
  {
    LispValue newSymbol;

    // First, check to see whether one exists already.
    newSymbol = pkg.getSymbol(symbolString);

    if (newSymbol != f_lisp.NIL)    // Already there, don't add it again.
View Full Code Here

    super(lisp, "STRING-NOT-GREATERP", 2);
  }

  public void Execute(SECDMachine machine)
  {
    LispValue arg2 = machine.S.pop();
    LispValue arg1 = machine.S.pop();

    machine.S.push(arg1.stringNotGreaterP(arg2));
    machine.C.pop();
  }
View Full Code Here

    super(lisp, "STRING>", 2);
  }

  public void Execute(SECDMachine machine)
  {
    LispValue arg2 = machine.S.pop();
    LispValue arg1 = machine.S.pop();

    machine.S.push(arg1.stringGreaterThan(arg2));
    machine.C.pop();
  }
View Full Code Here

    super(lisp, "ATAN2", 2);
  }

  public void Execute(SECDMachine machine)
  {
    LispValue arg2 = machine.S.pop();
    LispValue arg1 = machine.S.pop();

    machine.S.push(arg1.atan2(arg2));
    machine.C.pop();
  }
View Full Code Here

   * Input should be a regular string, which is parsed and evaluated.
   */
  public void eval(String inputString)
  {
    f_parent.message(inputString + "\n", true);
    LispValue result = f_lisp.load(inputString, true);
    if (result.basic_null())
      f_parent.message(";; *** ERROR - unbalanced parentheses in input\n", false);
    else
    {
      f_parent.addHistoryItem(inputString);

View Full Code Here

TOP

Related Classes of org.jatha.dynatype.LispValue

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.