AddLabel() public method

public AddLabel ( string label, ProgramClause procedure ) : void
label string
procedure ProgramClause
return void
コード例 #1
0
ファイル: AMProgram.cs プロジェクト: ahodroj/prologdotnet
        public void AddLabel_4()
        {
            ArrayList p = new ArrayList();
            HaltInstruction hi = new HaltInstruction();
            p.Add(hi);

            AMProgram program = new AMProgram();
            program.Initialize(p);

            program.AddLabel("male/1", new ProgramClause("male", 1));
            program.AddLabel("male/1", new ProgramClause("male", 1));
            program.AddLabel("male/1", new ProgramClause("male", 1));
            program.AddLabel("male/1", new ProgramClause("male", 1));

            ProgramClause male1 = program["male/1"];
            ProgramClause male2 = male1.NextPredicate;
            ProgramClause male3 = male2.NextPredicate;
            ProgramClause male4 = male3.NextPredicate;

            Assert.AreEqual(male1.Name, "male");
            Assert.AreEqual(male1.Arity, 1);
            Assert.AreEqual(male1.Instruction.Name(), "try_me_else");

            Assert.AreEqual(male2.Name, "male%1/1");
            Assert.AreEqual(male2.Arity, 1);
            Assert.AreEqual(male2.Instruction.Name(), "retry_me_else");

            Assert.AreEqual(male3.Name, "male%2/1");
            Assert.AreEqual(male3.Arity, 1);
            Assert.AreEqual(male3.Instruction.Name(), "retry_me_else");

            Assert.AreEqual(male4.Name, "male%3/1");
            Assert.AreEqual(male4.Arity, 1);
            Assert.AreEqual(male4.Instruction.Name(), "trust_me");
        }