node-print: upgrade to 15

This commit is contained in:
ptrcnull 2023-12-05 23:59:22 +01:00
parent 5db71a3ddd
commit 3b6a5effbd
Signed by: ptrcnull
GPG key ID: 411F7B30801DD9CA
4 changed files with 80 additions and 161 deletions

View file

@ -1,7 +1,7 @@
# Contributor: Patrycja Rosa <alpine@ptrcnull.me> # Contributor: Patrycja Rosa <alpine@ptrcnull.me>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me> # Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=node-print pkgname=node-print
pkgver=14 pkgver=15
pkgrel=0 pkgrel=0
pkgdesc="another terrible javascript engine wrapper" pkgdesc="another terrible javascript engine wrapper"
url="https://git.ddd.rip/ptrcnull/ptrcports" url="https://git.ddd.rip/ptrcnull/ptrcports"
@ -21,6 +21,8 @@ check() {
# ensure coverage # ensure coverage
local cov_lines="$(grep -F index.js output.txt | cut -d' ' -f4 | cut -d. -f1)" local cov_lines="$(grep -F index.js output.txt | cut -d' ' -f4 | cut -d. -f1)"
[ "$cov_lines" -gt 90 ] [ "$cov_lines" -gt 90 ]
local cov_branches="$(grep -F index.js output.txt | cut -d' ' -f6 | cut -d. -f1)"
[ "$cov_branches" -gt 90 ]
} }
package() { package() {
@ -30,6 +32,6 @@ package() {
sha512sums=" sha512sums="
b3dfdeb49637be33d2e2718c5abcf35a87dd55023918c99341273c3b38bd6685189d1f786451a742c47c5f3bc3b58555decb58e2a3a018c9b9ee92043f8fac03 np b3dfdeb49637be33d2e2718c5abcf35a87dd55023918c99341273c3b38bd6685189d1f786451a742c47c5f3bc3b58555decb58e2a3a018c9b9ee92043f8fac03 np
2f3c70b29b8bd3c5c357f4a3ab8bbf3c54dae5193850433310108685a53b6f089501253aa17b6695abf8c3e2944a3aadc7fccc42a3915e906f8b14df81cc610f index.js 8741fd49d035d28f93dcb417b65254fd7c60a3027287749cab11d71cbeca91ea8ae5c18fab739d5c4f90c3e0029c831a333003444b7c5ed1ef84888c97ffdae1 index.js
9b13784855f3d01b3ab89b15dce6c59949a103ed139e5d858720b064f248dd9bbeca57d7113eed818652f064714054b77a0d7d53097024ead84a21ad69d536d6 test.js 9b13784855f3d01b3ab89b15dce6c59949a103ed139e5d858720b064f248dd9bbeca57d7113eed818652f064714054b77a0d7d53097024ead84a21ad69d536d6 test.js
" "

View file

@ -26,6 +26,11 @@ String.prototype.includesAny = function(strings) {
return strings.some(x => this.includes(x)) return strings.some(x => this.includes(x))
} }
String.prototype.replaceAt = function(idx, str) {
if (idx > (this.length - 1) || idx < 0) throw new RangeError('idx must be in bounds of the string')
return this.substring(0, idx) + str + this.substring(idx + str.length)
}
String.prototype.tryParseJSON = function() { String.prototype.tryParseJSON = function() {
const str = this.trim() const str = this.trim()
if ( if (
@ -102,6 +107,14 @@ Array.prototype.product = function(def = 1) {
return this.reduce((a, b) => a * b, def) return this.reduce((a, b) => a * b, def)
} }
Array.prototype.min = function() {
return this.reduce((a, b) => Math.min(a, b))
}
Array.prototype.max = function() {
return this.reduce((a, b) => Math.max(a, b))
}
Array.prototype.sortNum = function(getter = (x => x)) { Array.prototype.sortNum = function(getter = (x => x)) {
return this.sort((a, b) => getter(a) - getter(b)) return this.sort((a, b) => getter(a) - getter(b))
} }

View file

@ -1,152 +0,0 @@
TAP version 13
# test output
# Subtest: Object.prototype.map
ok 1 - Object.prototype.map
---
duration_ms: 1.898781
...
# Subtest: Object.prototype.apply
ok 2 - Object.prototype.apply
---
duration_ms: 0.1012
...
# Subtest: String.prototype.lines
ok 3 - String.prototype.lines
---
duration_ms: 0.668277
...
# Subtest: String.prototype.reverse
ok 4 - String.prototype.reverse
---
duration_ms: 0.097609
...
# Subtest: String.prototype.includesAny
ok 5 - String.prototype.includesAny
---
duration_ms: 0.157079
...
# Subtest: String.prototype.tryParseJSON
ok 6 - String.prototype.tryParseJSON
---
duration_ms: 0.171079
...
# Subtest: Buffer.prototype.tryParseJSON
ok 7 - Buffer.prototype.tryParseJSON
---
duration_ms: 0.15631
...
# Subtest: exec
ok 8 - exec
---
duration_ms: 2.373978
...
# Subtest: exec.orFail
ok 9 - exec.orFail
---
duration_ms: 1.752591
...
# Subtest: execnc
ok 10 - execnc
---
duration_ms: 1.517843
...
# Subtest: apkindex
ok 11 - apkindex
---
duration_ms: 218.94233
...
# Subtest: Array.prototype.sum
ok 12 - Array.prototype.sum
---
duration_ms: 0.167829
...
# Subtest: Array.prototype.product
ok 13 - Array.prototype.product
---
duration_ms: 0.092419
...
# Subtest: Array.prototype.sortNum
ok 14 - Array.prototype.sortNum
---
duration_ms: 0.166239
...
# Subtest: Array.prototype.partition
ok 15 - Array.prototype.partition
---
duration_ms: 0.223309
...
# Subtest: Array.prototype.chunks - size 2, length 2n
ok 16 - Array.prototype.chunks - size 2, length 2n
---
duration_ms: 0.176819
...
# Subtest: Array.prototype.chunks - size 2, length 2n+1
ok 17 - Array.prototype.chunks - size 2, length 2n+1
---
duration_ms: 0.12053
...
# Subtest: Array.prototype.transpose
ok 18 - Array.prototype.transpose
---
duration_ms: 0.180939
...
# Subtest: Array.prototype.shuffle
ok 19 - Array.prototype.shuffle
---
duration_ms: 0.189319
...
# Subtest: Set.prototype.union
ok 20 - Set.prototype.union
---
duration_ms: 0.321928
...
# Subtest: Set.prototype.intersection
ok 21 - Set.prototype.intersection
---
duration_ms: 0.191079
...
# Subtest: Set.prototype.at - single element
ok 22 - Set.prototype.at - single element
---
duration_ms: 0.12324
...
# Subtest: Set.prototype.at - multiple elements
ok 23 - Set.prototype.at - multiple elements
---
duration_ms: 0.152549
...
# Subtest: matrix - seed with value
ok 24 - matrix - seed with value
---
duration_ms: 0.267349
...
# Subtest: matrix - seed with function
ok 25 - matrix - seed with function
---
duration_ms: 0.167019
...
# Subtest: Number.prototype.toXY
ok 26 - Number.prototype.toXY
---
duration_ms: 0.177589
...
# Subtest: Object.prune
ok 27 - Object.prune
---
duration_ms: 0.153959
...
1..27
# tests 27
# suites 0
# pass 27
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 313.645715
# start of coverage report
# file | line % | branch % | funcs % | uncovered lines
# index.js | 96.20 | 86.96 | 95.12 | 5, 6, 7, 171, 172, 173, 174
# test.js | 98.82 | 96.97 | 100.00 | 107, 108, 109
# all files | 97.72 | 90.20 | 97.22 |
# end of coverage report

View file

@ -30,7 +30,7 @@ test('String.prototype.lines', t => {
const str = 'one\ntwo\nthree\n' const str = 'one\ntwo\nthree\n'
assert.deepEqual( assert.deepEqual(
['one', 'two', 'three'], ['one', 'two', 'three'],
str.lines() str.trim().lines()
) )
assert.deepEqual( assert.deepEqual(
['one', 'two', 'three'], ['one', 'two', 'three'],
@ -50,6 +50,21 @@ test('String.prototype.includesAny', t => {
assert(str.includesAny(['test'])) assert(str.includesAny(['test']))
assert(str.includesAny(['not', 'test'])) assert(str.includesAny(['not', 'test']))
assert(!str.includesAny(['missing'])) assert(!str.includesAny(['missing']))
assert.throws(() => str.includesAny())
assert.throws(() => str.includesAny('a'))
})
test('String.prototype.replaceAt', t => {
const str = 'test string woof'
assert.equal(
'test strong woof',
str.replaceAt(8, 'o')
)
assert.equal(
'test longer string',
str.replaceAt(5, 'longer string')
)
assert.throws(() => str.replaceAt(str.length+10, 'out of bounds'))
}) })
test('String.prototype.tryParseJSON', t => { test('String.prototype.tryParseJSON', t => {
@ -100,6 +115,13 @@ test('execnc', t => {
) )
}) })
test('execnc with options', t => {
assert.equal(
undefined,
execnc('echo', ['test output2'], {}).stdout
)
})
test('apkindex', async t => { test('apkindex', async t => {
try { try {
await fs.access('/lib/apk/db/installed', fs.constants.R_OK) await fs.access('/lib/apk/db/installed', fs.constants.R_OK)
@ -134,6 +156,20 @@ test('Array.prototype.product', t => {
) )
}) })
test('Array.prototype.min', t => {
assert.equal(
2,
[5, 3, 2].min()
)
})
test('Array.prototype.max', t => {
assert.equal(
5,
[5, 3, 2].max()
)
})
test('Array.prototype.sortNum', t => { test('Array.prototype.sortNum', t => {
assert.deepEqual( assert.deepEqual(
[2, 3, 5], [2, 3, 5],
@ -178,6 +214,22 @@ test('Array.prototype.shuffle', t => {
) )
}) })
test('Array.prototype.uniq', t => {
const arr = [ 5, 5, 3, 8, 4, 6, 7, 2, 1, 2, 8 ]
assert.deepEqual(
[ 5, 3, 8, 4, 6, 7, 2, 1 ],
arr.uniq()
)
})
test('Array.prototype.lines', t => {
const arr = [ 'a', 'b', 'test' ]
assert.deepEqual(
'a\nb\ntest',
arr.lines()
)
})
test('Set.prototype.union', t => { test('Set.prototype.union', t => {
const left = new Set([1, 3]) const left = new Set([1, 3])
const right = new Set([2, 4]) const right = new Set([2, 4])
@ -185,6 +237,8 @@ test('Set.prototype.union', t => {
new Set([1, 2, 3, 4]), new Set([1, 2, 3, 4]),
left.union(right) left.union(right)
) )
assert.throws(() => left.union())
assert.throws(() => left.union(3))
}) })
test('Set.prototype.intersection', t => { test('Set.prototype.intersection', t => {
@ -194,6 +248,8 @@ test('Set.prototype.intersection', t => {
new Set([2]), new Set([2]),
left.intersection(right) left.intersection(right)
) )
assert.throws(() => left.intersection())
assert.throws(() => left.intersection(3))
}) })
test('Set.prototype.difference', t => { test('Set.prototype.difference', t => {
@ -207,6 +263,8 @@ test('Set.prototype.difference', t => {
new Set([4]), new Set([4]),
right.difference(left) right.difference(left)
) )
assert.throws(() => left.difference())
assert.throws(() => left.difference(3))
}) })
test('Set.prototype.at - single element', t => { test('Set.prototype.at - single element', t => {
@ -244,6 +302,8 @@ test('Number.prototype.toXY', t => {
[ 1, 3 ], [ 1, 3 ],
(16).toXY(5) (16).toXY(5)
) )
assert.throws(() => (5).toXY())
assert.throws(() => (5).toXY([]))
}) })
test('Object.prune', t => { test('Object.prune', t => {
@ -258,10 +318,6 @@ test('Object.prune', t => {
anotherEmptyProperty: undefined anotherEmptyProperty: undefined
}) })
) )
assert.throws(() => Object.prune())
assert.throws(() => Object.prune(5))
}) })
// test('String.prototype.reverse', t => {
// assert.equal(
// )
// })