<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_A2.2_T2</p>
<div id='console'></div>
<script>
try {

/**
 * @name: S7.1_A2.2_T2;
 * @section: 7.1;
 * @assertion: Since the format control character (Cf) are removed before processing regular expression literals,
 * one must use a Unicode escape sequence to include a Cf inside regular expression literal;
 * @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('var x = RegExp("' + format + 'a' + format + 'b' + format + '")');      
      if (x.source.length !== 5) {
        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>
