js/src/tests/ecma/extensions/15.5.4.4-4.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6
michael@0 7 /**
michael@0 8 File Name: 15.5.4.4-4.js
michael@0 9 ECMA Section: 15.5.4.4 String.prototype.charAt(pos)
michael@0 10 Description: Returns a string containing the character at position
michael@0 11 pos in the string. If there is no character at that
michael@0 12 string, the result is the empty string. The result is
michael@0 13 a string value, not a String object.
michael@0 14
michael@0 15 When the charAt method is called with one argument,
michael@0 16 pos, the following steps are taken:
michael@0 17 1. Call ToString, with this value as its argument
michael@0 18 2. Call ToInteger pos
michael@0 19 3. Compute the number of characters in Result(1)
michael@0 20 4. If Result(2) is less than 0 is or not less than
michael@0 21 Result(3), return the empty string
michael@0 22 5. Return a string of length 1 containing one character
michael@0 23 from result (1), the character at position Result(2).
michael@0 24
michael@0 25 Note that the charAt function is intentionally generic;
michael@0 26 it does not require that its this value be a String
michael@0 27 object. Therefore it can be transferred to other kinds
michael@0 28 of objects for use as a method.
michael@0 29
michael@0 30 This tests assiging charAt to primitive types..
michael@0 31
michael@0 32 Author: christine@netscape.com
michael@0 33 Date: 2 october 1997
michael@0 34 */
michael@0 35 var SECTION = "15.5.4.4-4";
michael@0 36 var VERSION = "ECMA_2";
michael@0 37 startTest();
michael@0 38 var TITLE = "String.prototype.charAt";
michael@0 39
michael@0 40 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 41
michael@0 42 /*
michael@0 43 new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "n", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") );
michael@0 44 new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "u", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") );
michael@0 45 new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "l", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") );
michael@0 46 new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "l", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") );
michael@0 47
michael@0 48 new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "u", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") );
michael@0 49 new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "n", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") );
michael@0 50 new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "d", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") );
michael@0 51 new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "e", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") );
michael@0 52 */
michael@0 53 new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "f", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") );
michael@0 54 new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "a", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") );
michael@0 55 new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "l", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") );
michael@0 56 new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "s", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") );
michael@0 57 new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(4)") );
michael@0 58
michael@0 59 new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "t", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") );
michael@0 60 new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "r", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") );
michael@0 61 new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "u", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") );
michael@0 62 new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "e", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") );
michael@0 63
michael@0 64 new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "N", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") );
michael@0 65 new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "a", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") );
michael@0 66 new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "N", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") );
michael@0 67
michael@0 68 new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") );
michael@0 69 new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "2", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") );
michael@0 70 new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "3", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") );
michael@0 71
michael@0 72
michael@0 73 test();

mercurial