public void CurrentTest() { Write("current.txt", "scary Variable "); StreamReader stream = new StreamReader("C:\\current.txt"); scanner = new PrologScanner(stream); scanner.Next(); Assert.AreEqual(PrologToken.ATOM, scanner.Current.Kind); scanner.Next(); Assert.AreEqual(PrologToken.VARIABLE, scanner.Current.Kind); stream.Close(); }
public void RParenTest() { Write("rparen.txt", " ) "); StreamReader stream = new StreamReader("C:\\rparen.txt"); scanner = new PrologScanner(stream); scanner.Next(); Assert.AreEqual(PrologToken.RPAREN, scanner.Current.Kind); stream.Close(); }
public void VariableTest() { Write("var.txt", "Father "); StreamReader stream = new StreamReader("C:\\var.txt"); scanner = new PrologScanner(stream); scanner.Next(); Assert.AreEqual(PrologToken.VARIABLE, scanner.Current.Kind); stream.Close(); }
public void AtomTest() { Write("atom.txt", " atom "); StreamReader stream = new StreamReader("C:\\atom.txt"); scanner = new PrologScanner(stream); scanner.Next(); Assert.AreEqual(PrologToken.ATOM, scanner.Current.Kind); stream.Close(); }
public void CommaTest() { Write("comma.txt", " , "); StreamReader stream = new StreamReader("C:\\comma.txt"); scanner = new PrologScanner(stream); scanner.Next(); Assert.AreEqual(PrologToken.COMMA, scanner.Current.Kind); stream.Close(); }
public void ListSepTest() { Write("sep.txt", " | "); StreamReader stream = new StreamReader("C:\\sep.txt"); scanner = new PrologScanner(stream); scanner.Next(); Assert.AreEqual(PrologToken.LIST_SEP, scanner.Current.Kind); stream.Close(); }
public void RBracketTest() { Write("rbra.txt", " ] "); StreamReader stream = new StreamReader("C:\\rbra.txt"); scanner = new PrologScanner(stream); scanner.Next(); Assert.AreEqual(PrologToken.RBRACKET, scanner.Current.Kind); stream.Close(); }
public void DotTest() { Write("dot.txt", " . "); StreamReader stream = new StreamReader("C:\\dot.txt"); scanner = new PrologScanner(stream); scanner.Next(); Assert.AreEqual(PrologToken.DOT, scanner.Current.Kind); stream.Close(); }
public void StringTest() { Write("string.txt", " 'This is a string' "); StreamReader stream = new StreamReader("C:\\string.txt"); scanner = new PrologScanner(stream); scanner.Next(); Assert.AreEqual(PrologToken.ATOM, scanner.Current.Kind); stream.Close(); }
public void FactTokensRule() { Write("fact_tokens.txt", "male(ali,hodroj,X,'Fine not really!',[A|B])."); StreamReader stream = new StreamReader("C:\\fact_tokens.txt"); scanner = new PrologScanner(stream); // male scanner.Next(); Assert.AreEqual(PrologToken.ATOM, scanner.Current.Kind); // ( scanner.Next(); Assert.AreEqual(PrologToken.LPAREN, scanner.Current.Kind); // ali scanner.Next(); Assert.AreEqual(PrologToken.ATOM, scanner.Current.Kind); // , scanner.Next(); Assert.AreEqual(PrologToken.COMMA, scanner.Current.Kind); // hodroj scanner.Next(); Assert.AreEqual(PrologToken.ATOM, scanner.Current.Kind); // , scanner.Next(); Assert.AreEqual(PrologToken.COMMA, scanner.Current.Kind); // X scanner.Next(); Assert.AreEqual(PrologToken.VARIABLE, scanner.Current.Kind); // , scanner.Next(); Assert.AreEqual(PrologToken.COMMA, scanner.Current.Kind); // 'Fine Not Really!' scanner.Next(); Assert.AreEqual(PrologToken.ATOM, scanner.Current.Kind); // , scanner.Next(); Assert.AreEqual(PrologToken.COMMA, scanner.Current.Kind); // [ scanner.Next(); Assert.AreEqual(PrologToken.LBRACKET, scanner.Current.Kind); // A scanner.Next(); Assert.AreEqual(PrologToken.VARIABLE, scanner.Current.Kind); // | scanner.Next(); Assert.AreEqual(PrologToken.LIST_SEP, scanner.Current.Kind); // B scanner.Next(); Assert.AreEqual(PrologToken.VARIABLE, scanner.Current.Kind); // ] scanner.Next(); Assert.AreEqual(PrologToken.RBRACKET, scanner.Current.Kind); // ) scanner.Next(); Assert.AreEqual(PrologToken.RPAREN, scanner.Current.Kind); // . scanner.Next(); Assert.AreEqual(PrologToken.DOT, scanner.Current.Kind); stream.Close(); }