From 33a175689e5757b4363b80eb95f16151e5f2489c Mon Sep 17 00:00:00 2001 From: David Fugate Date: Mon, 12 Sep 2011 13:34:49 -0700 Subject: [PATCH] Rebuilt website. --- website/resources/scripts/global/framework.js | 79 +++++++++++++++++++ .../resources/scripts/global/sputnikLib.js | 66 ++++++++-------- website/resources/scripts/global/sta.js | 22 +++--- website/resources/scripts/global/sth.js | 70 ++++++++-------- .../resources/scripts/testcases/15.12.json | 2 +- .../scripts/testcases/15.4.4.16.json | 2 +- .../scripts/testcases/15.4.4.17.json | 2 +- .../scripts/testcases/SputnikGlobalScope.js | 2 +- .../scripts/testcases/chapter07.json | 2 +- 9 files changed, 163 insertions(+), 84 deletions(-) create mode 100644 website/resources/scripts/global/framework.js diff --git a/website/resources/scripts/global/framework.js b/website/resources/scripts/global/framework.js new file mode 100644 index 0000000000..04164e18ce --- /dev/null +++ b/website/resources/scripts/global/framework.js @@ -0,0 +1,79 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +function Test262Error(message) { + this.message = message; +} + +Test262Error.prototype.toString = function () { + return "Test262 Error: " + this.message; +}; + +function testFailed(message) { + throw new Test262Error(message); +} + +function testPrint(message) { + +} + +/** + * It is not yet clear that runTestCase should pass the global object + * as the 'this' binding in the call to testcase. + */ +var runTestCase = (function(global) { + return function(testcase) { + if (!testcase.call(global)) { + testFailed('test function returned falsy'); + } + }; +})(this); + +function assertTruthy(value) { + if (!value) { + testFailed('test return falsy'); + } +} + + +/** + * falsy means we expect no error. + * truthy means we expect some error. + * A non-empty string means we expect an error whose .name is that string. + */ +var expectedErrorName = false; + +/** + * What was thrown, or the string 'Falsy' if something falsy was thrown. + * null if test completed normally. + */ +var actualError = null; + +function testStarted(expectedErrName) { + expectedErrorName = expectedErrName; +} + +function testFinished() { + var actualErrorName = actualError && (actualError.name || + 'SomethingThrown'); + if (actualErrorName) { + if (expectedErrorName) { + if (typeof expectedErrorName === 'string') { + if (expectedErrorName === actualErrorName) { + return; + } + testFailed('Threw ' + actualErrorName + + ' instead of ' + expectedErrorName); + } + return; + } + throw actualError; + } + if (expectedErrorName) { + if (typeof expectedErrorName === 'string') { + testFailed('Completed instead of throwing ' + + expectedErrorName); + } + testFailed('Completed instead of throwing'); + } +} diff --git a/website/resources/scripts/global/sputnikLib.js b/website/resources/scripts/global/sputnikLib.js index 447a03bdfc..5a22af167d 100644 --- a/website/resources/scripts/global/sputnikLib.js +++ b/website/resources/scripts/global/sputnikLib.js @@ -2,16 +2,16 @@ // Copyright 2009 the Sputnik authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. -function SputnikError(message) { +function Test262Error(message) { if (message) this.message = message; } -SputnikError.prototype.toString = function () { +Test262Error.prototype.toString = function () { return "Test262 Error: " + this.message; }; function testFailed(message) { - throw new SputnikError(message); + throw new Test262Error(message); } @@ -47,8 +47,8 @@ function $FAIL(message) { function getPrecision(num) { //TODO: Create a table of prec's, - // because using Math for testing Math isn't that correct. - + // because using Math for testing Math isn't that correct. + log2num = Math.log(Math.abs(num))/Math.LN2; pernum = Math.ceil(log2num); return(2 * Math.pow(2, -52 + pernum)); @@ -71,7 +71,7 @@ function isEqual(num1, num2) { return(true); } - prec = getPrecision(Math.min(Math.abs(num1), Math.abs(num2))); + prec = getPrecision(Math.min(Math.abs(num1), Math.abs(num2))); return(Math.abs(num1 - num2) <= prec); //return(num1 === num2); } @@ -86,10 +86,10 @@ function ToInteger(p) { if(isNaN(x)){ return +0; } - - if((x === +0) - || (x === -0) - || (x === Number.POSITIVE_INFINITY) + + if((x === +0) + || (x === -0) + || (x === Number.POSITIVE_INFINITY) || (x === Number.NEGATIVE_INFINITY)){ return x; } @@ -170,10 +170,10 @@ function YearFromTime(t) { t = Number(t); var sign = ( t < 0 ) ? -1 : 1; var year = ( sign < 0 ) ? 1969 : 1970; - + for(var time = 0;;year += sign){ time = TimeFromYear(year); - + if(sign > 0 && time > t){ year -= sign; break; @@ -184,11 +184,11 @@ function YearFromTime(t) { }; return year; } - + function InLeapYear(t){ if(DaysInYear(YearFromTime(t)) == 365) return 0; - + if(DaysInYear(YearFromTime(t)) == 366) return 1; } @@ -247,7 +247,7 @@ var LocalTZA = $LocalTZ*msPerHour; function DaysInMonth(m, leap) { m = m%12; - + //April, June, Sept, Nov if(m == 3 || m == 5 || m == 8 || m == 10 ) { return 30; @@ -266,7 +266,7 @@ function GetSundayInMonth(t, m, count){ var year = YearFromTime(t); var leap = InLeapYear(t); var day = 0; - + if(m >= 1) day += DaysInMonth(0, leap); if(m >= 2) day += DaysInMonth(1, leap); if(m >= 3) day += DaysInMonth(2, leap); @@ -278,25 +278,25 @@ function GetSundayInMonth(t, m, count){ if(m >= 9) day += DaysInMonth(8, leap); if(m >= 10) day += DaysInMonth(9, leap); if(m >= 11) day += DaysInMonth(10, leap); - + var month_start = TimeFromYear(year)+day*msPerDay; var sunday = 0; - + if(count === "last"){ - for(var last_sunday = month_start+DaysInMonth(m, leap)*msPerDay; + for(var last_sunday = month_start+DaysInMonth(m, leap)*msPerDay; WeekDay(last_sunday)>0; last_sunday -= msPerDay ){}; sunday = last_sunday; } else { - for(var first_sunday = month_start; + for(var first_sunday = month_start; WeekDay(first_sunday)>0; first_sunday += msPerDay ){}; sunday = first_sunday+7*msPerDay*(count-1); } - + return sunday; } @@ -306,9 +306,9 @@ function DaylightSavingTA(t) { var DST_start = GetSundayInMonth(t, $DST_start_month, $DST_start_sunday) +$DST_start_hour*msPerHour +$DST_start_minutes*msPerMinute; - + var k = new Date(DST_start); - + var DST_end = GetSundayInMonth(t, $DST_end_month, $DST_end_sunday) +$DST_end_hour*msPerHour +$DST_end_minutes*msPerMinute; @@ -412,7 +412,7 @@ function MakeDate( day, time ) { if(!isFinite(day) || !isFinite(time)) { return Number.NaN; } - + return day*msPerDay+time; } @@ -445,20 +445,20 @@ function ConstructDate(year, month, date, hours, minutes, seconds, ms){ var r1 = Number(year); var r2 = Number(month); var r3 = ((date && arguments.length > 2) ? Number(date) : 1); - var r4 = ((hours && arguments.length > 3) ? Number(hours) : 0); - var r5 = ((minutes && arguments.length > 4) ? Number(minutes) : 0); - var r6 = ((seconds && arguments.length > 5) ? Number(seconds) : 0); + var r4 = ((hours && arguments.length > 3) ? Number(hours) : 0); + var r5 = ((minutes && arguments.length > 4) ? Number(minutes) : 0); + var r6 = ((seconds && arguments.length > 5) ? Number(seconds) : 0); var r7 = ((ms && arguments.length > 6) ? Number(ms) : 0); - + var r8 = r1; - + if(!isNaN(r1) && (0 <= ToInteger(r1)) && (ToInteger(r1) <= 99)) r8 = 1900+r1; - + var r9 = MakeDay(r8, r2, r3); var r10 = MakeTime(r4, r5, r6, r7); var r11 = MakeDate(r9, r10); - + return TimeClip(UTC(r11)); } @@ -466,9 +466,9 @@ function ConstructDate(year, month, date, hours, minutes, seconds, ms){ /**** Python code for initialize the above constants // We may want to replicate the following in JavaScript. -// However, using JS date operations to generate parameters that are then used to +// However, using JS date operations to generate parameters that are then used to // test those some date operations seems unsound. However, it isn't clear if there -//is a good interoperable alternative. +//is a good interoperable alternative. # Copyright 2009 the Sputnik authors. All rights reserved. # This code is governed by the BSD license found in the LICENSE file. diff --git a/website/resources/scripts/global/sta.js b/website/resources/scripts/global/sta.js index 3deea039d9..bcb9346905 100644 --- a/website/resources/scripts/global/sta.js +++ b/website/resources/scripts/global/sta.js @@ -1,14 +1,14 @@ -/// Copyright (c) 2009 Microsoft Corporation -/// +/// Copyright (c) 2009 Microsoft Corporation +/// /// Redistribution and use in source and binary forms, with or without modification, are permitted provided -/// that the following conditions are met: +/// that the following conditions are met: /// * Redistributions of source code must retain the above copyright notice, this list of conditions and -/// the following disclaimer. -/// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and -/// the following disclaimer in the documentation and/or other materials provided with the distribution. +/// the following disclaimer. +/// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and +/// the following disclaimer in the documentation and/or other materials provided with the distribution. /// * Neither the name of Microsoft nor the names of its contributors may be used to /// endorse or promote products derived from this software without specific prior written permission. -/// +/// /// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR /// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE @@ -16,7 +16,7 @@ /// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS /// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, /// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -/// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //----------------------------------------------------------------------------- function compareArray(aExpected, aActual) { @@ -121,10 +121,10 @@ function fnGlobalObject() { //----------------------------------------------------------------------------- function fnSupportsStrict() { "use strict"; - try { - eval('with ({}) {}'); + try { + eval('with ({}) {}'); return false; - } catch (e) { + } catch (e) { return true; } } diff --git a/website/resources/scripts/global/sth.js b/website/resources/scripts/global/sth.js index 234cb7a931..9c6f4d3397 100644 --- a/website/resources/scripts/global/sth.js +++ b/website/resources/scripts/global/sth.js @@ -1,14 +1,14 @@ -/// Copyright (c) 2009 Microsoft Corporation -/// +/// Copyright (c) 2009 Microsoft Corporation +/// /// Redistribution and use in source and binary forms, with or without modification, are permitted provided -/// that the following conditions are met: +/// that the following conditions are met: /// * Redistributions of source code must retain the above copyright notice, this list of conditions and -/// the following disclaimer. -/// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and -/// the following disclaimer in the documentation and/or other materials provided with the distribution. +/// the following disclaimer. +/// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and +/// the following disclaimer in the documentation and/or other materials provided with the distribution. /// * Neither the name of Microsoft nor the names of its contributors may be used to /// endorse or promote products derived from this software without specific prior written permission. -/// +/// /// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR /// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS /// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE @@ -16,7 +16,7 @@ /// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS /// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, /// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -/// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //Do not cache any JSON files - see https://bugs.ecmascript.org/show_bug.cgi?id=87 $.ajaxSetup( {cache:false}); @@ -68,7 +68,7 @@ function BrowserRunner() { currentTest.description = "Failed to load test case!"; } else if((typeof currentTest.error) !== "undefined") { // We have an error logged from testRun. - if(currentTest.error instanceof SputnikError) { + if(currentTest.error instanceof Test262Error) { currentTest.error = currentTest.message; } else { currentTest.error = currentTest.error.name + ": " + currentTest.error.message; @@ -119,11 +119,11 @@ function BrowserRunner() { // Set up some globals. iwin.testRun = testRun; iwin.testFinished = testFinished; - + //TODO: these should be moved to sta.js var includes = code.match(/\$INCLUDE\(([^\)]+)\)/g), // find all of the $INCLUDE statements include; - iwin.SputnikError = SputnikError; + iwin.Test262Error = Test262Error; iwin.$ERROR = $ERROR; iwin.$FAIL = $FAIL; iwin.$PRINT = function () {}; @@ -139,15 +139,15 @@ function BrowserRunner() { $.ajax({ async: false, url: 'resources/scripts/global/' + include, - success: function(s) { scriptCache[include] = s } - }) + success: function(s) { scriptCache[include] = s; } + }); } // Finally, write the required script to the window. idoc.writeln(""); } } - + //Write out all of our helper functions //idoc.writeln(""); idoc.writeln(""); idoc.writeln(""); - + //Run the code idoc.writeln("