public void testFactConstructor(){
        try{
            try{
                StringReader sr = new StringReader("");
                Lex lex = new Lex(sr);
                ExtendedFact fact = new ExtendedFact(lex);
                assertTrue(false);
            }catch(ParserException e){
                assertTrue(true);
            };

            try{
                StringReader sr = new StringReader("==('A','B','C'");
                Lex lex = new Lex(sr);
                ExtendedFact fact = new ExtendedFact(lex);
                assertTrue(false);
            }catch(ParserException e){
                assertTrue(true);
            };

            try{
                StringReader sr = new StringReader("A");
                Lex lex = new Lex(sr);
                ExtendedFact fact = new ExtendedFact(lex);
                assertTrue(false);
            }catch(ParserException e){
                assertTrue(true);
            };

            try{
                StringReader sr = new StringReader("A(");
                Lex lex = new Lex(sr);
                ExtendedFact fact = new ExtendedFact(lex);
                assertTrue(false);
            }catch(ParserException e){
                assertTrue(true);
            };

            try{
                StringReader sr = new StringReader("A()");
                Lex lex = new Lex(sr);
                ExtendedFact fact =
                    new ExtendedFact(lex);
                assertTrue(false);
            }catch(ParserException e){
                assertTrue(true);
            };

            try{
                StringReader sr = new StringReader("A('A' 'B')");
                Lex lex = new Lex(sr);
                ExtendedFact fact =
                    new ExtendedFact(lex);
                assertTrue(false);
            }catch(ParserException e){
                assertTrue(true);
            };

            try{
                StringReader sr = new StringReader("A('X',)");
                Lex lex = new Lex(sr);
                ExtendedFact fact =
                    new ExtendedFact(lex);
                assertTrue(false);
            }catch(ParserException e){
                assertTrue(true);
            };

            try{
                StringReader sr = new StringReader("A('X')");
                Lex lex = new Lex(sr);
                ExtendedFact fact =
                    new ExtendedFact(lex);
                assertTrue(false);
            }catch(ParserException e){
                assertTrue(true);
            };

            StringReader sr = new StringReader("Apple('Id1').");
            Lex lex = new Lex(sr);
            ExtendedFact fact = new ExtendedFact(lex);

            ArrayList<Node> nodes = fact.getNodes();
            assertTrue(nodes.get(0) instanceof Constant);
            assertTrue(((Token)nodes.get(0)).getValue().equals("'Id1'"));
            assertTrue(fact.getName().getValue().equals("Apple"));
            assertTrue(fact.toString().equals("Apple('Id1')."));

            sr = new StringReader("M('Id1',\n 'Id2').");
            lex = new Lex(sr);
            fact = new ExtendedFact(lex);
            nodes = fact.getNodes();
            assertTrue(nodes.size() == 2);
            assertTrue(nodes.get(0) instanceof Constant);
            assertTrue(nodes.get(1) instanceof Constant);
            assertTrue(((Token)nodes.get(0)).getValue().equals("'Id1'"));
            assertTrue(((Token)nodes.get(1)).getValue().equals("'Id2'"));
            assertTrue(fact.getName().getValue().equals("M"));
            assertTrue(fact.toString().equals("M('Id1','Id2')."));

            sr = new StringReader("List('Name1',\n 'Name2',\n 'Name3').");
            lex = new Lex(sr);
            fact = new ExtendedFact(lex);
            nodes = fact.getNodes();
            assertTrue(nodes.size() == 3);
            assertTrue(nodes.get(0) instanceof Constant);
            assertTrue(nodes.get(1) instanceof Constant);
            assertTrue(nodes.get(2) instanceof Constant);
            assertTrue(((Token)nodes.get(0)).getValue().equals("'Name1'"));
            assertTrue(((Token)nodes.get(1)).getValue().equals("'Name2'"));
            assertTrue(((Token)nodes.get(2)).getValue().equals("'Name3'"));
            assertTrue(fact.getName().getValue().equals("List"));
            assertTrue(fact.toString().equals(
                 "List('Name1','Name2','Name3')."));
        }catch(ParserException e){
            System.out.println(
                "ERROR in FactTest.testFactConstructor\n" +
                "    should not get here.\n" +
                "    error = " + e.getMessage());
        };
    }