Last active
March 25, 2018 22:49
-
-
Save zeddkay/8de670467d3f4109d426424ee534a30d to your computer and use it in GitHub Desktop.
Updated tests according to https://wiki.cdot.senecacollege.ca/wiki/OSD600_and_DPS909_Winter_2018_Lab_4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2009 the Sputnik authors. All rights reserved. | |
// This code is governed by the BSD license found in the LICENSE file. | |
/*--- | |
info: Check ToLength(length) for non Array objects | |
esid: sec-array.prototype.reverse | |
es5id: 15.4.4.8_A3_T3 | |
description: length = -4294967294 | |
---*/ | |
//PREVIOUS | |
var obj = {}; | |
obj.reverse = Array.prototype.reverse; | |
obj[0] = "x"; | |
obj[1] = "y"; | |
obj[2] = "z"; | |
obj.length = -4294967294; | |
//CHECK#1 | |
var reverse = obj.reverse(); | |
/* | |
if (reverse !== obj) { | |
$ERROR('#1: var obj = {}; obj.reverse = Array.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse() === obj. Actual: ' + (reverse)); | |
} | |
*/ | |
//NEW | |
assert.sameValue(reverse, obj, "reverse equal to obj?"); | |
//CHECK#2 | |
if (obj.length !== -4294967294) { | |
$ERROR('#2: var obj = {}; obj.reverse = Array.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse(); obj.length === -4294967294. Actual: ' + (obj.length)); | |
} | |
//NEW | |
assert.sameValue(obj.length, -4294967294, "obj.length == -4294967294?"); | |
//CHECK#3 | |
/* | |
if (obj[0] !== "x") { | |
$ERROR('#3: var obj = {}; obj.reverse = Array.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse(); obj[0] === "x". Actual: ' + (obj[0])); | |
} | |
*/ | |
//NEW | |
assert.sameValue(obj[0], "x", "ob[0] == x"); | |
//CHECK#4 | |
/* | |
if (obj[1] !== "y") { | |
$ERROR('#4: var obj = {}; obj.reverse = Array.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse(); obj[1] === "y". Actual: ' + (obj[1])); | |
} | |
*/ | |
//NEW | |
assert.sameValue(obj[1], "y", "ob[1] == y"); | |
//CHECK#5 | |
/* | |
if (obj[2] !== "z") { | |
$ERROR('#5: var obj = {}; obj.reverse = Array.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse(); obj[2] === "z". Actual: ' + (obj[2])); | |
} | |
*/ | |
//NEW | |
assert.sameValue(obj[2], "z", "ob[2] == z"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment