Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Commit f94b97b

Browse files
author
Face Kapow
committed
everything except js/core/net
1 parent ae461ee commit f94b97b

5 files changed

Lines changed: 93 additions & 109 deletions

File tree

js/test/unit/platform/index.js

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
// limitations under the License.
1414

1515
'use strict';
16-
var test = require('tape');
16+
const test = require('tape');
1717

1818
/* global TextEncoder */
1919
/* global TextDecoder */
2020

21-
test('__SYSCALL.eval valid code', function(t) {
21+
test('__SYSCALL.eval valid code', (t) => {
2222
global.a = 10;
2323
__SYSCALL.eval('a++');
2424
t.equal(global.a, 11);
2525
t.end();
2626
});
2727

28-
test('__SYSCALL.eval invalid code', function(t) {
28+
test('__SYSCALL.eval invalid code', (t) => {
2929
t.plan(1);
3030

3131
try {
@@ -35,7 +35,7 @@ test('__SYSCALL.eval invalid code', function(t) {
3535
}
3636
});
3737

38-
test('__SYSCALL.eval throws', function(t) {
38+
test('__SYSCALL.eval throws', (t) => {
3939
t.plan(2);
4040

4141
try {
@@ -46,23 +46,17 @@ test('__SYSCALL.eval throws', function(t) {
4646
}
4747
});
4848

49-
test('TextEncoder and TextDecoder', function(t) {
50-
var encoder = new TextEncoder('utf-8');
51-
var decoder = new TextDecoder('utf-8');
52-
var u8 = encoder.encode('test string');
49+
test('TextEncoder and TextDecoder', (t) => {
50+
const encoder = new TextEncoder('utf-8');
51+
const decoder = new TextDecoder('utf-8');
52+
const u8 = encoder.encode('test string');
5353
t.ok(u8 instanceof Uint8Array);
5454
t.equal(decoder.decode(u8), 'test string');
5555
t.end();
5656
});
5757

58-
test('TextEncoder and TextDecoder call as a function', function(t) {
59-
t.throws(function() {
60-
TextEncoder('utf-8');
61-
});
62-
63-
t.throws(function() {
64-
TextDecoder('utf-8');
65-
});
66-
58+
test('TextEncoder and TextDecoder call as a function', (t) => {
59+
t.throws(() => TextEncoder('utf-8')); // eslint-disable-line new-cap
60+
t.throws(() => TextDecoder('utf-8')); // eslint-disable-line new-cap
6761
t.end();
6862
});

js/test/unit/random/index.js

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,57 +13,56 @@
1313
// limitations under the License.
1414

1515
'use strict';
16-
var test = require('tape');
17-
var runtime = require('../../../core');
18-
var EntropySource = require('../../../core/random/entropy-source');
1916

20-
test('EntropySource', function(t) {
17+
const test = require('tape');
18+
const runtime = require('../../../core');
19+
const EntropySource = require('../../../core/random/entropy-source');
20+
21+
test('EntropySource', (t) => {
2122
t.timeoutAfter(1000);
2223

23-
var source = new EntropySource('test-source');
24-
source.ongetbytes = function(u8, cb) {
25-
for (var i = 0; i < u8.length; ++i) {
26-
u8[i] = 0x33 + i;
27-
}
24+
const source = new EntropySource('test-source');
25+
source.ongetbytes = (u8, cb) => {
26+
for (let i = 0; i < u8.length; ++i) u8[i] = 0x33 + i;
2827
cb();
2928
};
3029

31-
var u8 = new Uint8Array(3);
32-
source.getBytes(u8, function() {
30+
const u8 = new Uint8Array(3);
31+
source.getBytes(u8, () => {
3332
t.equal(u8[0], 0x33);
3433
t.equal(u8[1], 0x34);
3534
t.equal(u8[2], 0x35);
3635
t.end();
3736
});
3837
});
3938

40-
test('getTrueRandomValues buffer', function(t) {
39+
test('getTrueRandomValues buffer', (t) => {
4140
t.timeoutAfter(1000);
42-
var u8 = new Uint8Array([0, 0, 0]);
43-
runtime.random.getTrueRandomValues(u8, function(u8out) {
41+
const u8 = new Uint8Array([0, 0, 0]);
42+
runtime.random.getTrueRandomValues(u8, (u8out) => {
4443
t.equal(u8, u8out);
4544
t.end();
4645
});
4746
});
4847

49-
test('getTrueRandomValues length', function(t) {
48+
test('getTrueRandomValues length', (t) => {
5049
t.timeoutAfter(1000);
51-
runtime.random.getTrueRandomValues(4, function(u8) {
50+
runtime.random.getTrueRandomValues(4, (u8) => {
5251
t.ok(u8 instanceof Uint8Array);
5352
t.equal(u8.length, 4);
5453
t.end();
5554
});
5655
});
5756

58-
test('getRandomValues buffer', function(t) {
59-
var u8 = new Uint8Array([0, 0, 0]);
60-
var u8out = runtime.random.getRandomValues(u8);
57+
test('getRandomValues buffer', (t) => {
58+
const u8 = new Uint8Array([0, 0, 0]);
59+
const u8out = runtime.random.getRandomValues(u8);
6160
t.equal(u8, u8out);
6261
t.end();
6362
});
6463

65-
test('getRandomValues length', function(t) {
66-
var u8 = runtime.random.getRandomValues(10);
64+
test('getRandomValues length', (t) => {
65+
const u8 = runtime.random.getRandomValues(10);
6766
t.ok(u8 instanceof Uint8Array);
6867
t.equal(u8.length, 10);
6968
t.end();

js/test/unit/script/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
'use strict';
1616

17-
var test = require('tape');
17+
const test = require('tape');
1818

19-
test('div by zero should not trigger CPU Divide Error exception', function(t) {
20-
var v = 10;
19+
test('div by zero should not trigger CPU Divide Error exception', (t) => {
20+
const v = 10;
2121
t.equal(v / 0, Infinity);
2222
t.end();
2323
});
2424

25-
test('some math functions (in case they rely on embedded libc)', function(t) {
25+
test('some math functions (in case they rely on embedded libc)', (t) => {
2626
t.equal(Math.abs(-45.4), 45.4);
2727
t.equal(Math.acos(-0.2).toFixed(2), '1.77');
2828
t.equal((Math.atan2(1, 0) * 2).toFixed(2), '3.14');
@@ -33,12 +33,12 @@ test('some math functions (in case they rely on embedded libc)', function(t) {
3333
t.end();
3434
});
3535

36-
test('Math.random', function(t) {
36+
test('Math.random', (t) => {
3737
t.equal(typeof Math.random(), 'number');
3838
t.end();
3939
});
4040

41-
test('Date object', function(t) {
41+
test('Date object', (t) => {
4242
t.equal(typeof new Date(), 'object');
4343
t.end();
4444
});

js/test/unit/timers/index.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,23 @@
1414

1515
'use strict';
1616

17-
var test = require('tape');
17+
const test = require('tape');
1818

19-
test('setTimeout', function(t) {
20-
setTimeout(t.end.bind(t), 0);
21-
});
19+
test('setTimeout', t => setTimeout(t.end.bind(t), 0));
2220

23-
test('setImmediate', function(t) {
24-
setImmediate(t.end.bind(t));
25-
});
21+
test('setImmediate', t => setImmediate(t.end.bind(t)));
2622

27-
test('clearTimeout', function(t) {
28-
var timer = setTimeout(function() {
23+
test('clearTimeout', (t) => {
24+
const timer = setTimeout(() => {
2925
t.fail('should not call callback');
3026
throw new Error('should not call callback');
3127
}, 0);
3228
clearTimeout(timer);
3329
setTimeout(t.end.bind(t), 0);
3430
});
3531

36-
test('clearInterval', function(t) {
37-
var timer = setInterval(function() {
32+
test('clearInterval', (t) => {
33+
const timer = setInterval(() => {
3834
t.fail('should not call callback');
3935
throw new Error('should not call callback');
4036
}, 0);

0 commit comments

Comments
 (0)