blob: 6e0345ff2767a87747a881af6bc93e19dc750842 [file] [log] [blame]
<html>
<head>
<meta charset='utf-8'>
<style>
.pass {
font-weight: bold;
color: green;
}
.fail {
font-weight: bold;
color: red;
}
</style>
<script>
if (window.testRunner)
testRunner.dumpAsText();
function SputnikError(message)
{
this.message = message;
}
SputnikError.prototype.toString = function ()
{
return 'SputnikError: ' + this.message;
};
var sputnikException;
function testPrint(msg)
{
var span = document.createElement("span");
document.getElementById("console").appendChild(span); // insert it first so XHTML knows the namespace
span.innerHTML = msg + '<br />';
}
function escapeHTML(text)
{
return text.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;");
}
function printTestPassed(msg)
{
testPrint('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
}
function printTestFailed(msg)
{
testPrint('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
}
function testFailed(msg)
{
throw new SputnikError(msg);
}
var successfullyParsed = false;
</script>
</head>
<body>
<p>S9.9_A5</p>
<div id='console'></div>
<script>
try {
/**
* @name: S9.9_A5;
* @section: 9.9;
* @assertion: ToObject conversion from String: create a new String object
* whose [[value]] property is set to the value of the string;
* @description: Converting from various strings to Object;
*/
// CHECK#1
if (Object("some string").valueOf() !== "some string"){
testFailed('#1: Object("some string").valueOf() === "some string". Actual: ' + (Object("some string").valueOf()));
}
// CHECK#2
if (typeof Object("some string") !== "object"){
testFailed('#2: typeof Object("some string") === "object". Actual: ' + (typeof Object("some string")));
}
// CHECK#3
if (Object("some string").constructor.prototype !== String.prototype){
testFailed('#3: Object("some string").constructor.prototype === String.prototype. Actual: ' + (Object("some string").constructor.prototype));
}
// CHECK#4
if (Object("").valueOf() !== ""){
testFailed('#4: Object("").valueOf() === false. Actual: ' + (Object("").valueOf()));
}
// CHECK#5
if (typeof Object("") !== "object"){
testFailed('#5: typeof Object("") === "object". Actual: ' + (typeof Object("")));
}
// CHECK#6
if (Object("").constructor.prototype !== String.prototype){
testFailed('#6: Object("").constructor.prototype === String.prototype. Actual: ' + (Object("").constructor.prototype));
}
// CHECK#7
if (Object("\r\t\b\n\v\f").valueOf() !== "\r\t\b\n\v\f"){
testFailed('#7: Object("\\r\\t\\b\\n\\v\\f").valueOf() === false. Actual: ' + (Object("\r\t\b\n\v\f").valueOf()));
}
// CHECK#8
if (typeof Object("\r\t\b\n\v\f") !== "object"){
testFailed('#8: typeof Object("\\r\\t\\b\\n\\v\\f") === "object". Actual: ' + (typeof Object("\r\t\b\n\v\f")));
}
// CHECK#9
if (Object("\r\t\b\n\v\f").constructor.prototype !== String.prototype){
testFailed('#9: Object("\\r\\t\\b\\n\\v\\f").constructor.prototype === String.prototype. Actual: ' + (Object("\r\t\b\n\v\f").constructor.prototype));
}
// CHECK#10
if (Object(String(10)).valueOf() !== "10"){
testFailed('#10: Object(String(10)).valueOf() === false. Actual: ' + (Object(String(10)).valueOf()));
}
// CHECK#11
if (typeof Object(String(10)) !== "object"){
testFailed('#11: typeof Object(String(10)) === "object". Actual: ' + (typeof Object(String(10))));
}
// CHECK#12
if (Object(String(10)).constructor.prototype !== String.prototype){
testFailed('#12: Object(String(10)).constructor.prototype === String.prototype. Actual: ' + (Object(String(10)).constructor.prototype));
}
} catch (ex) {
sputnikException = ex;
}
var successfullyParsed = true;
</script>
<script>
if (!successfullyParsed)
printTestFailed('successfullyParsed is not set');
else if (sputnikException)
printTestFailed(sputnikException);
else
printTestPassed("");
testPrint('<br /><span class="pass">TEST COMPLETE</span>');
</script>
</body>
</html>