rm array proto funcs

This commit is contained in:
2026-01-21 00:52:18 -06:00
parent ef49606098
commit 26fce3a5a8
31 changed files with 259 additions and 372 deletions

View File

@@ -109,7 +109,7 @@ function makeTest(test) {
var testarr = []
for (var i = 0; i < 500; i++) {
testarr.push(1)
push(testarr, 1)
}
var testCases = [

View File

@@ -561,14 +561,14 @@ return {
test_array_push: function() {
var arr = [1, 2]
arr.push(3)
push(arr, 3)
if (length(arr) != 3) throw "array push length failed"
if (arr[2] != 3) throw "array push value failed"
},
test_array_pop: function() {
var arr = [1, 2, 3]
var val = arr.pop()
var val = pop(arr)
if (val != 3) throw "array pop value failed"
if (length(arr) != 2) throw "array pop length failed"
},
@@ -1474,39 +1474,6 @@ return {
// ARRAY METHODS
// ============================================================================
test_array_shift: function() {
var arr = [1, 2, 3]
var first = arr.shift()
if (first != 1) throw "array shift value failed"
if (length(arr) != 2) throw "array shift length failed"
if (arr[0] != 2) throw "array shift remaining failed"
},
test_array_unshift: function() {
var arr = [2, 3]
arr.unshift(1)
if (length(arr) != 3) throw "array unshift length failed"
if (arr[0] != 1) throw "array unshift value failed"
},
test_array_splice: function() {
var arr = [1, 2, 3, 4, 5]
var removed = arr.splice(1, 2)
if (length(removed) != 2) throw "array splice removed length failed"
if (removed[0] != 2) throw "array splice removed values failed"
if (length(arr) != 3) throw "array splice remaining length failed"
if (arr[1] != 4) throw "array splice remaining values failed"
},
test_array_slice: function() {
var arr = [1, 2, 3, 4, 5]
var sliced = array(arr, 1, 3)
if (length(sliced) != 2) throw "array slice length failed"
if (sliced[0] != 2) throw "array slice first failed"
if (sliced[1] != 3) throw "array slice second failed"
if (length(arr) != 5) throw "array slice should not mutate original"
},
test_array_concat: function() {
var arr1 = [1, 2]
var arr2 = [3, 4]
@@ -2102,7 +2069,7 @@ return {
test_function_proxy_args_array_is_real_array: function() {
var proxy = function(name, args) {
if (!is_array(args)) throw "args should be array"
args.push(4)
push(args, 4)
return length(args)
}
var result = proxy.test(1, 2, 3)
@@ -3135,7 +3102,7 @@ return {
test_arrfor_with_index: function() {
var arr = ["a", "b", "c"]
var indices = []
arrfor(arr, (x, i) => { indices.push(i) })
arrfor(arr, (x, i) => { push(indices, i) })
if (indices[0] != 0 || indices[2] != 2) throw "arrfor with index failed"
},
@@ -3148,7 +3115,7 @@ return {
test_arrfor_mutation: function() {
var arr = [1, 2, 3]
var results = []
arrfor(arr, x => { results.push(x * 2) })
arrfor(arr, x => { push(results, x * 2) })
if (results[0] != 2 || results[1] != 4 || results[2] != 6) throw "arrfor mutation failed"
},

View File

@@ -58,7 +58,7 @@ function deep_compare(expected, actual, path) {
}
var testarr = []
for (var i = 0; i < 500; i++) { testarr.push(1) }
for (var i = 0; i < 500; i++) { push(testarr, 1) }
var testCases = [
{ name: 'zero', input: 0 },