mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-17 15:54:07 +10:00
Patched some very obscure bugs
This commit is contained in:
23
test/scripts/polyfill-remove.toy
Normal file
23
test/scripts/polyfill-remove.toy
Normal file
@@ -0,0 +1,23 @@
|
||||
//polyfill the remove function
|
||||
fn _remove(self, k) {
|
||||
var result = [];
|
||||
|
||||
for (var i = 0; i <= k - 1; i++) {
|
||||
result.push( self[i] );
|
||||
}
|
||||
|
||||
for (var i = k + 1; i < self.length(); i++) {
|
||||
result.push( self[i] );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
var a = [1, 2, 3];
|
||||
|
||||
assert a.remove(0) == [2, 3], "polyfill remove(start) failed";
|
||||
assert a.remove(1) == [1, 3], "polyfill remove(middle) failed";
|
||||
assert a.remove(2) == [1, 2], "polyfill remove(end) failed";
|
||||
|
||||
|
||||
print "All good";
|
||||
Reference in New Issue
Block a user