Skip to content

Instantly share code, notes, and snippets.

@thanpolas
Created February 22, 2013 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thanpolas/5014065 to your computer and use it in GitHub Desktop.
Save thanpolas/5014065 to your computer and use it in GitHub Desktop.
phantomJS failing on array sort
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>JS tests</title>
<meta name="description" content="tests">
<meta name="viewport" content="width=device-width">
<script type="text/javascript" src="qunit/qunit/qunit.js"></script>
<link rel="stylesheet" href="qunit/qunit/qunit.css" type="text/css" media="screen" />
</head>
<body>
<div>
<script type="text/javascript">
(function(){
var anchor = {
href: 'index.html?compiled=true',
value: 'Compiled Mode'
};
if(QUnit.urlParams.compiled) {
anchor.href = 'index.html';
anchor.value = 'Uncompiled Mode';
}
document.write('<a href="' + anchor.href + '">' + anchor.value + '<\/a>');
})();
</script>
</div>
<h1 id="qunit-header">Unit Tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
<script type="text/javascript">
(function(){
module('PhantomJS');
test('Array sorting', function() {
expect(2);
stop();
var arNum = [2, 4, 1];
var arObj = [
{name: 'two', val: 20},
{name: 'three', val: 30},
{name: 'one', val: 10}
];
function sortObj(a, b) { return a.val < b.val; }
function sortNum(a, b) { return a < b; }
Array.prototype.sort.call(arObj, sortObj);
Array.prototype.sort.call(arNum, sortNum);
equal(arNum[1], 2, 'Array with numbers, second item should be num 2');
equal(arObj[1].name, 'two', 'Array with Objects, second item should be "two"');
start();
});
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment