rhino1.7.6.testsrc.tests.ecma.String.15.5.4.4-1.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rhino Show documentation
Show all versions of rhino Show documentation
Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically
embedded into Java applications to provide scripting to end users.
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
gTestfile = '15.5.4.4-1.js';
/**
File Name: 15.5.4.4-1.js
ECMA Section: 15.5.4.4 String.prototype.charAt(pos)
Description: Returns a string containing the character at position
pos in the string. If there is no character at that
string, the result is the empty string. The result is
a string value, not a String object.
When the charAt method is called with one argument,
pos, the following steps are taken:
1. Call ToString, with this value as its argument
2. Call ToInteger pos
In this test, this is a String, pos is an integer, and
all pos are in range.
Author: [email protected]
Date: 2 october 1997
*/
var SECTION = "15.5.4.4-1";
var VERSION = "ECMA_1";
startTest();
var TITLE = "String.prototype.charAt";
writeHeaderToLog( SECTION + " "+ TITLE);
var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" );
var item = 0;
var i;
for ( i = 0x0020; i < 0x007e; i++, item++) {
new TestCase( SECTION,
"TEST_STRING.charAt("+item+")",
String.fromCharCode( i ),
TEST_STRING.charAt( item ) );
}
for ( i = 0x0020; i < 0x007e; i++, item++) {
new TestCase( SECTION,
"TEST_STRING.charAt("+item+") == TEST_STRING.substring( "+item +", "+ (item+1) + ")",
true,
TEST_STRING.charAt( item ) == TEST_STRING.substring( item, item+1 )
);
}
new TestCase( SECTION, "String.prototype.charAt.length", 1, String.prototype.charAt.length );
print( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" );
test();
© 2015 - 2024 Weber Informatics LLC | Privacy Policy