-
-
Save AbdulKabia/d5d9dddb14b9eb91cfb8e9af6b4c5afe to your computer and use it in GitHub Desktop.
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: > | |
The elements of the array are rearranged so as to reverse their order. | |
The object is returned as the result of the call | |
esid: sec-array.prototype.reverse | |
es5id: 15.4.4.8_A1_T2 | |
description: Checking this algorithm, elements are objects and primitives | |
---*/ | |
//CHECK#1 | |
var x = ["1", "NaN", undefined, "Jimmy", "Abdul"]; | |
// x[0] = true; | |
// x[2] = Infinity; | |
// x[4] = undefined; | |
// x[5] = undefined; | |
// x[8] = "NaN"; | |
// x[9] = "-1"; | |
var reverse = x.reverse(); | |
// CHECK#1 | |
if (reverse !== x) { | |
$ERROR('#1: x = [ "1", "NaN", undefined, "Jimmy"]; x[0] = 1; x[1] = NaN; x[2] = undefined; x[3] = Jimmy; x.reverse() === x. Actual: ' + (reverse)); | |
} | |
// CHECK#2 | |
if (x[0] !== "Abdul") { | |
$ERROR('#2: x = [ "1", "NaN", undefined, "Jimmy"]; x[0] = 1; x[1] = NaN; x[2] = undefined; x[3] = Jimmy; x.reverse(); x[0] === "Abdul". Actual: ' + (x[0])); | |
} | |
// CHECK#3 | |
if (x[1] !== "Jimmy") { | |
$ERROR('#3: x = [ "1", "NaN", undefined, "Jimmy"]; x[0] = 1; x[1] = NaN; x[2] = undefined; x[3] = Jimmy; x.reverse(); x[1] === "Jimmy". Actual: ' + (x[1])); | |
} | |
// CHECK#4 | |
if (x[2] !== undefined) { | |
$ERROR('#4: x = [ "1", "NaN", undefined, "Jimmy"]; x[0] = 1; x[1] = NaN; x[2] = undefined; x[3] = Jimmy; x.reverse(); x[2] === undefined. Actual: ' + (x[2])); | |
} | |
// CHECK#5 | |
if (x[3] !== "NaN") { | |
$ERROR('#5: x = [ "1", "NaN", undefined, "Jimmy"]; x[0] = 1; x[1] = NaN; x[2] = undefined; x[3] = Jimmy; x.reverse(); x[3] === "NaN". Actual: ' + (x[3])); | |
} | |
// CHECK#6 | |
if (x[4] !== "1") { | |
$ERROR('#6: x = [ "1", "NaN", undefined, "Jimmy"]; x[0] = 1; x[1] = NaN; x[2] = undefined; x[3] = Jimmy; x.reverse(); x[4] === "1". Actual: ' + (x[4])); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment