コード例 #1
0
        public void ReverseSortBy()
        {
            ArrayList arrayList = new ArrayList();
            arrayList.Add(new BELInteger(1));
            arrayList.Add(new BELInteger(2));
            arrayList.Add(new BELInteger(3));
            arrayList.Add(new BELInteger(0));

            BELArray unsorted = new BELArray(arrayList);

            // Create a simple arithmetic mapping for the sort
            BehaviorParser parser = new BehaviorParser("");
            ExposableParseTreeNode block = parser.Parse("4.Subtract(e)");

            ArrayList parameters = new ArrayList();
            BlockParameter parameter = new BlockParameter(null, "e");
            parameters.Add(parameter);

            BELArray sorted = unsorted.ReverseSortBy(new ExecutionContext(), new Block(block, parameters, null));

            Assert.AreEqual(4, sorted.Count, "Checking that the length was preserved.");

            for (int i = 0; i < 4; ++i)
            {
                Assert.AreEqual(i, ((BELInteger)sorted.Item(i)).Value, "Checking that sort order was correct.");
            }
        }
コード例 #2
0
ファイル: ExecutionTests.cs プロジェクト: nuxleus/flexwiki
		string Run(string input, int wikiTalkVersion)
		{
			BehaviorParser parser = new BehaviorParser();
			ExposableParseTreeNode obj = parser.Parse(input);
			Assert.IsNotNull(obj);
			ExecutionContext ctx = new ExecutionContext();
			ctx.WikiTalkVersion = wikiTalkVersion;
			IBELObject evaluated = obj.Expose(ctx);
			IOutputSequence seq = evaluated.ToOutputSequence();
			return OutputSequenceToString(seq);
		}
コード例 #3
0
        public void ReverseSortByEmpty()
        {
            BELArray unsorted = new BELArray();

            // Create a simple arithmetic mapping for the sort
            BehaviorParser parser = new BehaviorParser("");
            ExposableParseTreeNode block = parser.Parse("4.Subtract(e)");

            ArrayList parameters = new ArrayList();
            BlockParameter parameter = new BlockParameter(null, "e");
            parameters.Add(parameter);

            BELArray sorted = unsorted.ReverseSortBy(new ExecutionContext(), new Block(block, parameters, null));

            Assert.IsNotNull(sorted, "Checking that result was returned for an empty array.");
            Assert.AreEqual(0, sorted.Count, "Checking that the result array was empty.");
        }