Add spec for circular array/object references
This commit is contained in:
parent
b06e6e9ce5
commit
ab1786c17d
2 changed files with 22 additions and 0 deletions
|
@ -44,6 +44,25 @@ describe('ipc module', function () {
|
||||||
comparePaths(path.normalize(remote.process.mainModule.filename), path.resolve(__dirname, 'static', 'main.js'))
|
comparePaths(path.normalize(remote.process.mainModule.filename), path.resolve(__dirname, 'static', 'main.js'))
|
||||||
comparePaths(path.normalize(remote.process.mainModule.paths[0]), path.resolve(__dirname, 'static', 'node_modules'))
|
comparePaths(path.normalize(remote.process.mainModule.paths[0]), path.resolve(__dirname, 'static', 'node_modules'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('handles circular references in arrays and objects', function () {
|
||||||
|
var a = remote.require(path.join(fixtures, 'module', 'circular.js'))
|
||||||
|
var array1 = ['foo']
|
||||||
|
var array2 = [array1, 'bar']
|
||||||
|
array1.push(array2)
|
||||||
|
assert.deepEqual(a.returnArgs(array1, array2), [
|
||||||
|
['foo', [[], 'bar']],
|
||||||
|
[]
|
||||||
|
])
|
||||||
|
|
||||||
|
var object1 = {foo: 'bar'}
|
||||||
|
var object2 = {baz: object1}
|
||||||
|
object1.object2 = object2
|
||||||
|
assert.deepEqual(a.returnArgs(object1, object2), [
|
||||||
|
{foo: 'bar', object2: {baz: {foo: 'bar', object2: null}}},
|
||||||
|
{baz: null}
|
||||||
|
])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('remote.createFunctionWithReturnValue', function () {
|
describe('remote.createFunctionWithReturnValue', function () {
|
||||||
|
|
3
spec/fixtures/module/circular.js
vendored
Normal file
3
spec/fixtures/module/circular.js
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
exports.returnArgs = function (...args) {
|
||||||
|
return args
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue