<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>S7.1_A1_T1</p>
<div id='console'></div>
<script>
try {

/**
 * @name: S7.1_A1_T1;
 * @section: 7.1;
 * @assertion: The format control character (Cf) can occur anywhere in the source text 
 * and these characters are removed before applying the lexical grammar;  
 * @description: Complex test with eval;
*/

//CHECK#1
Cf = [[0x00AD, 0x00AD], [0x0600, 0x0603], [0x06DD, 0x06DD], [0x070F, 0x070F], [0x17B4, 0x17B5], [0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2064], [0x206A, 0x206F], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB]];

errorCount = 0;
count = 0;
for (indexI = 0; indexI < Cf.length; indexI++) {
  for (indexJ = Cf[indexI][0]; indexJ <= Cf[indexI][1]; indexJ++) {
    try {
      var format = String.fromCharCode(indexJ);
      var hex = decimalToHexString(indexJ);
      eval(format);
      eval(format + "var " + format + "x" + format + "=" + format + "1" + format);
      eval(format);
      if (x !== 1) {
        testFailed('#' + hex + ' ');
        errorCount++;
      }
    } catch (e) {
      testFailed('#' + hex + ' ');
      errorCount++;
    }
    count++;
  }
}

if (errorCount > 0) {  
  testFailed('Total error: ' + errorCount + ' bad Unicode character in ' + count);
}

function decimalToHexString(n) {
  n = Number(n);
  var h = "";
  for (var i = 3; i >= 0; i--) {
    if (n >= Math.pow(16, i)) {
      var t = Math.floor(n / Math.pow(16, i));
      n -= t * Math.pow(16, i);
      if ( t >= 10 ) {
        if ( t == 10 ) { h += "A"; }
        if ( t == 11 ) { h += "B"; }
        if ( t == 12 ) { h += "C"; }
        if ( t == 13 ) { h += "D"; }
        if ( t == 14 ) { h += "E"; }
        if ( t == 15 ) { h += "F"; }
      } else {
        h += String(t);
      }
    } else {
      h += "0";
    }
  }
  return h;
}

} 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>
