blob: f904d7d24d338a6a63c62a61ff1a5a9a4358f209 [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>S12.13_A3_T6</p>
<div id='console'></div>
<script>
try {
/**
* @name: S12.13_A3_T6;
* @section: 12.13;
* @assertion: 1. Evaluate Expression;
* @description: Evaluating functions;
*/
// CHECK#1
var i=0;
function adding1(){
i++;
return 1;
}
try{
throw (adding1());
}
catch(e){
if (e!==1) testFailed('#1: Exception ===1. Actual: Exception ==='+ e);
}
// CHECK#2
var i=0;
function adding2(){
i++;
return i;
}
try{
throw adding2();
}
catch(e){}
if (i!==1) testFailed('#2: i===1. Actual: i==='+ i);
// CHECK#3
var i=0;
function adding3(){
i++;
}
try{
throw adding3();
}
catch(e){}
if (i!==1) testFailed('#3: i===1. Actual: i==='+i);
// CHECK#4
function adding4(i){
i++;
return i;
}
try{
throw (adding4(1));
}
catch(e){
if (e!==2) testFailed('#4: Exception ===2. Actual: Exception ==='+ e);
}
} 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>