public void atom_1_list() { AbstractMachineState state = SetupMachine(); AMProgram program = (AMProgram)state.Program; _p = new AtomPredicate(); AbstractTerm X0 = (AbstractTerm)state["X0"]; X0.Assign(new ListTerm()); Choicepoint b = new Choicepoint(); ProgramClause nextClause = new ProgramClause(); state.B = new Choicepoint(0, null, null, b, nextClause, 2, null); Verify("atom", 1); _p.Execute(state); Assert.AreSame(nextClause, program.P); }
public void var_1_unbound() { AbstractMachineState state = SetupMachine(); AMProgram program = (AMProgram)state.Program; _p = new VarPredicate(); AbstractTerm X0 = (AbstractTerm)state["X0"]; Choicepoint b = new Choicepoint(); ProgramClause nextClause = new ProgramClause(); state.B = new Choicepoint(0, null, null, b, nextClause, 2, null); Verify("var", 1); _p.Execute(state); Assert.AreNotSame(nextClause, program.P); }
public void write_1() { AbstractMachineState state = SetupMachine(); _p = new WritePredicate(); Verify("write", 1); _p.Execute(state); }
public void string_1_string() { AbstractMachineState state = SetupMachine(); AMProgram program = (AMProgram)state.Program; _p = new CharPredicate(); AbstractTerm X0 = (AbstractTerm)state["X0"]; X0.Assign(new ConstantTerm("a")); Choicepoint b = new Choicepoint(); ProgramClause nextClause = new ProgramClause(); state.B = new Choicepoint(0, null, null, b, nextClause, 2, null); Verify("char", 1); _p.Execute(state); Assert.AreNotSame(nextClause, program.P); }
public void unify_2() { AbstractMachineState state = SetupMachine(); _p = new UnifyPredicate(); AbstractTerm X0 = (AbstractTerm)state["X0"]; AbstractTerm X1 = (AbstractTerm)state["X1"]; X1.Assign(new ConstantTerm("ali")); Verify("=", 2); _p.Execute(state); Assert.AreEqual(X0.Data(), X1.Data()); Assert.AreEqual("ali", X0.Data()); }
public void put_1() { AbstractMachineState state = SetupMachine(); _p = new PutPredicate(); AbstractTerm x0 = (AbstractTerm)state["X0"]; x0.Assign(new ConstantTerm("61")); Verify("put", 1); _p.Execute(state); }
public void skip_1() { AbstractMachineState state = SetupMachine(); _p = new SkipPredicate(); Verify("skip", 1); _p.Execute(state); }
public void notunifiable_2() { AbstractMachineState state = SetupMachine(); AMProgram program = (AMProgram)state.Program; _p = new NotUnifiablePredicate(); AbstractTerm X0 = (AbstractTerm)state["X0"]; AbstractTerm X1 = (AbstractTerm)state["X1"]; X0.Assign(new ConstantTerm("ali")); X1.Assign(new ConstantTerm("ali")); Choicepoint b = new Choicepoint(); ProgramClause nextClause = new ProgramClause(); state.B = new Choicepoint(0, null, null, b, nextClause, 2, null); Verify("\\=", 2); _p.Execute(state); Assert.AreSame(nextClause, program.P); }
public void nl_0() { AbstractMachineState state = SetupMachine(); _p = new NlPredicate(); Verify("nl", 0); _p.Execute(state); }
public void lessthan_2() { AbstractMachineState state = SetupMachine(); AMProgram program = (AMProgram)state.Program; _p = new LessThanPredicate(); Verify("<", 2); AbstractTerm X0 = (AbstractTerm)state["X0"]; AbstractTerm X1 = (AbstractTerm)state["X1"]; Choicepoint b = new Choicepoint(); ProgramClause nextClause = new ProgramClause(); state.B = new Choicepoint(0, null, null, b, nextClause, 2, null); X0.Assign(new ConstantTerm("5")); X1.Assign(new ConstantTerm("1")); // X0 < X1 _p.Execute(state); Assert.AreSame(nextClause, program.P); }
public void get0_1() { AbstractMachineState state = SetupMachine(); _p = new Get0Predicate(); Verify("get0", 1); _p.Execute(state); }
public void call_1() { AbstractMachineState state = SetupMachine(); AMProgram program = (AMProgram)state.Program; _p = new CallPredicate(); Verify("call", 1); AbstractTerm X0 = (AbstractTerm)state["X0"]; StructureTerm goal = new StructureTerm("male", 1); goal.Next = new ConstantTerm("ali"); program.AddLabel("male/1", new ProgramClause("male", 1)); X0.Assign(goal); _p.Execute(state); Assert.AreEqual(X0.Data(), "ali"); ProgramClause p = (ProgramClause)program.P; Assert.AreEqual(p.Name, "male"); Assert.AreEqual(p.Arity, 1); }