test("object", (t) => {
let list = new List(42, null);
assert.strictEqual(list.first,42);
assert.strictEqual(list.rest,null);
});
test("one node",
(t)=>{
let list1 = new List("hello",null)
assert.strictEqual(list1.length(),1);
});
test("two nodes",
(t)=>{
let list2 = new List ("hello", new List("world", null));
assert.strictEqual(list2.length(),2);
});
test("big list",
(t)=>{
let list3 = null;
for (let i=0; i<100; i++){
list3= new List (i,list3);
}
assert.strictEqual(list3.length(),100);
});
test("iterator 1",
(t)=>{
let list2 = new List ("hello", new List("world", null));
result="";
for (let val of list2) {
result+=val;
}
assert.strictEqual(result,"helloworld");
});
test("iterator 2",
(t)=>{
let list3 = null;
for (let i=0; i<100; i++){
list3= new List (i,list3);
}
let result = 0;
for (let val of list3) {
result+=val;
}
assert.strictEqual(result, 4950);
});