Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: flip assertion arguments for make-callback/test.js #23470

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions test/addons/make-callback/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,39 @@ const vm = require('vm');
const binding = require(`./build/${common.buildType}/binding`);
const makeCallback = binding.makeCallback;

assert.strictEqual(42, makeCallback(process, common.mustCall(function() {
assert.strictEqual(0, arguments.length);
assert.strictEqual(this, process);
assert.strictEqual(makeCallback(process, common.mustCall(function() {
assert.strictEqual(arguments.length, 0);
assert.strictEqual(process, this);
return 42;
})));
})), 42);

assert.strictEqual(42, makeCallback(process, common.mustCall(function(x) {
assert.strictEqual(1, arguments.length);
assert.strictEqual(this, process);
assert.strictEqual(makeCallback(process, common.mustCall(function(x) {
assert.strictEqual(arguments.length, 1);
assert.strictEqual(process, this);
assert.strictEqual(x, 1337);
return 42;
}), 1337));
}), 1337), 42);

const recv = {
one: common.mustCall(function() {
assert.strictEqual(0, arguments.length);
assert.strictEqual(this, recv);
assert.strictEqual(arguments.length, 0);
assert.strictEqual(recv, this);
return 42;
}),
two: common.mustCall(function(x) {
assert.strictEqual(1, arguments.length);
assert.strictEqual(this, recv);
assert.strictEqual(arguments.length, 1);
assert.strictEqual(recv, this);
assert.strictEqual(x, 1337);
return 42;
}),
};

assert.strictEqual(42, makeCallback(recv, 'one'));
assert.strictEqual(42, makeCallback(recv, 'two', 1337));
assert.strictEqual(makeCallback(recv, 'one'), 42);
assert.strictEqual(makeCallback(recv, 'two', 1337), 42);

// Check that callbacks on a receiver from a different context works.
const foreignObject = vm.runInNewContext('({ fortytwo() { return 42; } })');
assert.strictEqual(42, makeCallback(foreignObject, 'fortytwo'));
assert.strictEqual(makeCallback(foreignObject, 'fortytwo'), 42);

// Check that the callback is made in the context of the receiver.
const target = vm.runInNewContext(`
Expand All @@ -48,7 +48,7 @@ const target = vm.runInNewContext(`
return Object;
})
`);
assert.notStrictEqual(Object, makeCallback(process, target, Object));
assert.notStrictEqual(makeCallback(process, target, Object), Object);

// Runs in inner context.
const forward = vm.runInNewContext(`
Expand All @@ -62,4 +62,4 @@ function endpoint($Object) {
throw new Error('bad');
return Object;
}
assert.strictEqual(Object, makeCallback(process, forward, endpoint));
assert.strictEqual(makeCallback(process, forward, endpoint), Object);