lib: consistent `this` in callbacks
This change normalizes a few situations where a callback might be invoked with this
set to undefined
in one case, but null
in a very similar case.
First commit:
test: refactor test-fs-stat
* add `use strict'
* change checks that `this` is mapped to `global` in sloppy mode to
checks that `this` is `undefined`
* modify arguments to assertions to match docs (actual first, expected
second)
* add blank line below `common` declaration per test writing guide
* use `assert.ifError()` as appropriate
Second commit:
fs: invoke callbacks with undefined context
Many callbacks appear to be invoked with `this` set to `undefined`
including `fs.stat()`, `fs.lstat()`, and `fs.fstat()`.
However, some such as `fs.open()` and `fs.mkdtemp()` invoke their
callbacks with `this` set to `null`.
Use a consistent way to invoke callbacks to guarantee consistency.
Third commit:
test: check `this` value for `nextTick()`
Depending on how many arguments are provided, `nextTick()` may run its
callback with `this` set to `null` or not. Add assertions for
both cases.
Fourth commit:
process: make `this` value consistent
The value of `this` for callbacks of `nextTick()` can vary depending on
the number of arguments. Make it consistent.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines
Affected core subsystem(s)
test process lib fs