KingNET.WebUI/Scripts/linqjs/test/enumerable.js
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/// <reference path="testrunner.htm"/>
module("Enumerable");
test("Choice", function ()
{
actual = Enumerable.Choice(1, 10, 31, 42).Take(10).ToArray();
notEqual(actual, [1, 10, 31, 42, 1, 10, 31, 42, 1, 10], "random test. if failed retry");
equal(actual.length, 10);
actual = Enumerable.Choice([1, 10, 31, 42]).Take(10).ToArray();
notEqual(actual, [1, 10, 31, 42, 1, 10, 31, 42, 1, 10], "random test. if failed retry");
equal(actual.length, 10);
});
test("Cycle", function ()
{
actual = Enumerable.Cycle(1, 10, 31, 42).Take(10).ToArray();
deepEqual(actual, [1, 10, 31, 42, 1, 10, 31, 42, 1, 10]);
actual = Enumerable.Cycle([1, 2, 3, 4, 5]).Take(10).ToArray();
deepEqual(actual, [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]);
});
test("Empty", function ()
{
actual = Enumerable.Empty().ToArray();
deepEqual(actual, []);
});
test("From", function ()
{
actual = Enumerable.From("temp").ToArray();
deepEqual(actual, ["t", "e", "m", "p"]);
actual = Enumerable.From(3).ToArray();
deepEqual(actual, [3]);
actual = Enumerable.From([1, 2, 3, 4, 5]).ToArray();
deepEqual(actual, [1, 2, 3, 4, 5]);
actual = Enumerable.From({ foo: "bar", func: function () { } }).ToArray();
deepEqual(actual, [{ Key: "foo", Value: "bar"}]);
var div = document.createElement("html");
var last = document.createElement("div");
last.appendChild(document.createTextNode("test"));
div.appendChild(document.createElement("div"));
div.appendChild(document.createElement("div"));
div.appendChild(last);
var seq = Enumerable.From(div.getElementsByTagName("div"));
equal(seq.Count(), 3);
equal(seq.ElementAt(2), last);
equal(seq.ElementAt(2).firstChild.nodeValue, "test");
});
test("Return", function ()
{
actual = Enumerable.Return("hoge").ToArray();
deepEqual(actual, ["hoge"]);
});
后面还有 91 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。