1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/Date/15.9.5.2-2-n.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,50 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + File Name: 15.9.5.2-2.js 1.12 + ECMA Section: 15.9.5.2 Date.prototype.toString 1.13 + Description: 1.14 + This function returns a string value. The contents of the string are 1.15 + implementation dependent, but are intended to represent the Date in a 1.16 + convenient, human-readable form in the current time zone. 1.17 + 1.18 + The toString function is not generic; it generates a runtime error if its 1.19 + this value is not a Date object. Therefore it cannot be transferred to 1.20 + other kinds of objects for use as a method. 1.21 + 1.22 + 1.23 + This verifies that calling toString on an object that is not a string 1.24 + generates a runtime error. 1.25 + 1.26 + Author: christine@netscape.com 1.27 + Date: 12 november 1997 1.28 +*/ 1.29 + 1.30 +var SECTION = "15.9.5.2-2"; 1.31 +var VERSION = "ECMA_1"; 1.32 +startTest(); 1.33 +var TITLE = "Date.prototype.toString"; 1.34 + 1.35 +writeHeaderToLog( SECTION + " "+ TITLE); 1.36 + 1.37 +var OBJ = new MyObject( new Date(0) ); 1.38 + 1.39 +DESCRIPTION = "var OBJ = new MyObject( new Date(0) ); OBJ.toString()"; 1.40 +EXPECTED = "error"; 1.41 + 1.42 +new TestCase( SECTION, 1.43 + "var OBJ = new MyObject( new Date(0) ); OBJ.toString()", 1.44 + "error", 1.45 + eval("OBJ.toString()") ); 1.46 +test(); 1.47 + 1.48 +function MyObject( value ) { 1.49 + this.value = value; 1.50 + this.valueOf = new Function( "return this.value" ); 1.51 + this.toString = Date.prototype.toString; 1.52 + return this; 1.53 +}