fix comments and multiple lines in the shell

This commit is contained in:
Eliot Horowitz
2009-09-01 13:50:08 -04:00
parent 3ee681be36
commit 81bfbb9faa

View File

@@ -151,6 +151,12 @@ bool isBalanced( string code ){
for ( size_t i=0; i<code.size(); i++ ){
switch( code[i] ){
case '/':
if ( i+1 < code.size() && code[i+1] == '/' ){
while ( i<code.size() && code[i] != '\n' )
i++;
}
continue;
case '{': brackets++; break;
case '}': brackets--; break;
case '(': parens++; break;
@@ -179,6 +185,8 @@ public:
assert( isBalanced( "function(){\n}" ) );
assert( ! isBalanced( "function(){" ) );
assert( isBalanced( "x = \"{\";" ) );
assert( isBalanced( "// {" ) );
assert( ! isBalanced( "// \n {" ) );
}
} balnaced_test;