SyntaxHighlighter Test

<< Back to overview page

a = 1;

a = 0.1;

a = .1;

a = 0x;

a = 0xfF1;

a = 0XE;

a = 1e1;

a = 1E1;

a = 1e+1;

a = 1e-1;

a = 1.e1;

a = 0xe+1;

a = 1 .method();

a = 1..method();

a = 0.1.method();

a = .1.method();

a = 1e1.method();

a = 00.method();

a = 0x.method();

a = 0xF.method();

a = "x";

a = "x\
y";

"x";

a = 'x';

a = "x'y";

a = 'x"y';

a = "x\"y";

a = "x\\\"y";

a = "x\\";

a = /regexp/;

/regexp/;

/regexp/g;

/"regexp"/;

/reg[/]exp/;

/reg\/exp/;

/regexp//1;

/\/*regexp*/;

/[/*regexp*/]/;

!!/regexp/;

((/regexp/));

[[/regexp/]];

a = 1/2/3;

a = a/1/2;

a = a++/1/2;

a = this/1/2;

a = (1)/2/3;

a = []/1/2;

a = {}/1/2;

({}/1/2);

+{}/1/2;

{}/regexp/;

/regexp/
/1/2;

function(){}
/regexp/

do /regexp/.test('x') while(false);

true ? {} : {}/1/2;

a = a
/1/2;

var a
/regexp/;

a = 1
/2/3;

a = 1//comment

a = 1/2// comment

a = 1 / 2; // comment

a = 1//comment
/2/3;

a = 1/*comment*//2;

a = 1+/*comment*/1/2;

a = 1/**//2;

/*/ comment /*/

/*/\*
comment
*/

// /* */ comment

a2 = 1;

π = 1;

\u0061 = 1;

a\u03c0 = 1;

a\u01Acπ = 1;



/*************************/
/* end of main testsuite */
/*************************/



if (true)
{
  a = {
    b: (function()
    {
      c = {
        d: {}
      };
    }()),
    x: function()
    {
      var b = 1 ? {} : {};
      a: {
        // labelled block
      }
      switch (true)
      {
        case 1 : yeah; break;
        case 2 : {
          blockStuff();
          a = {};
        }
        default : {
          blockStuff();
        }
      }
    },
    y: 2
  }
}

var a1 = "I like \"ponies\"\
they are fun.";
var a2 = 1/2/3 + 5e3; // funny number
var b = 0xfbe3D; /* multiline com..
...ment */50
alert(a+b);

var arr = [];
arr[0] = /[/]/;
arr[1] = (1)/2;
arr[2] = "1"/2;
arr[3] = /a//1;
arr[4] = /\//;
arr[5] = true/1;
arr[6] = false/1;
arr[7] = null/1;
arr[8] = this/1;
arr[9] = getReg();
arr[10] = {}/1;

{}/a/;
var a = {}/1;

function getReg()
{
  return /a/;
}

do /a/ while (!/a/);

a < b ; a >= b ; a === b;
a > b ; a <= b ; a !== b;
a + b ; a == b ; a >> b;
a - b ; a != b ; a << b;
a * b ; a += b ; a >>> b;
a / b ; a *= b ; a <<< b; // fake one '<<<' does not exist in JS
a % b ; a /= b ; a >>= b;
a & b ; a -= b ; a <<= b;
a | b ; a %= b ; a >>>= b;
a ^ b ; a &= b ;
a ++  ; a |= b ;
a --  ; a ^= b ;
a && b ;
a || b ;

if (b || b>=1 && b<=50)
{

}

str.replace(/\&/g, '&').replace(/</g, '<').replace(/\r\n|\r|\n/g,'<br>');


/foo/;  // a slash starting a line treated as a regexp beginning
"foo".match(/fo+$/);
// this line comment not treated as a regular expressions
"foo /bar/".test(/"baz"/);  // test string and regexp boundaries
var division = /\b\d+\/\d+/g;  // test char sets and escaping of specials
var allSpecials = /([^\(\)\[\]\{\}\-\?\+\*\.\^\$\/]+)\\/;
var slashInCharset = /[^/]/g, notCloseSq = /[^\]]/;

// test that slash used in numeric context treated as an operator
1 / 2;
1. / x;
x / y;
(x) / y;
1 /* foo */ / 2;
1 /* foo *// 2;
1/2;
1./x;
x/y;
(x)/y;

// test split over two lines.  line comment should not fool it
1//
/2;

x++/y;
x--/y;
x[y] / z;
f() / n;

// test that slash after non postfix operator is start of regexp
log('matches = ' + /foo/.test(foo));

// test keyword preceders
return /a regexp/;
division = notreturn / not_a_regexp / 2;  // keyword suffix does not match