From 8bd80f49117d6a772584a8d93dface0fb31ad931 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 6 Jan 2012 10:22:18 -0800 Subject: [PATCH] fix test-sys for hash randomization broken in 4a899c92742583ca9e0bb7d16e09a66b08c9d033 --- test/simple/test-sys.js | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/test/simple/test-sys.js b/test/simple/test-sys.js index bc2859a7a..cc3499178 100644 --- a/test/simple/test-sys.js +++ b/test/simple/test-sys.js @@ -60,17 +60,29 @@ assert.equal('{ visible: 1 }', common.inspect(Object.create({}, {visible: {value: 1, enumerable: true}, hidden: {value: 2}})) ); -assert.equal('{ [hidden]: 2, visible: 1 }', - common.inspect(Object.create({}, - {visible: {value: 1, enumerable: true}, hidden: {value: 2}}), true) -); + +// Due to the hash seed randomization it's not deterministic the order that +// the following ways this hash is displayed. +// See http://codereview.chromium.org/9124004/ + +var out = common.inspect(Object.create({}, + {visible: {value: 1, enumerable: true}, hidden: {value: 2}}), true); +if (out !== '{ [hidden]: 2, visible: 1 }' && + out !== '{ visible: 1, [hidden]: 2 }') { + assert.ok(false); +} + // Objects without prototype -assert.equal('{ [hidden]: \'secret\', name: \'Tim\' }', - common.inspect(Object.create(null, - {name: {value: 'Tim', enumerable: true}, - hidden: {value: 'secret'}}), true) -); +var out = common.inspect(Object.create(null, + { name: {value: 'Tim', enumerable: true}, + hidden: {value: 'secret'}}), true); +if (out !== "{ [hidden]: 'secret', name: 'Tim' }" && + out !== "{ name: 'Tim', [hidden]: 'secret' }") { + assert(false); +} + + assert.equal('{ name: \'Tim\' }', common.inspect(Object.create(null, {name: {value: 'Tim', enumerable: true}, -- 2.34.1