Ticket #3504: 3504_2.patch

File 3504_2.patch, 1.8 KB (added by Frederico Caldeira Knabben, 15 years ago)
  • _source/includes/scriptcompressor.js

     
    881881                                {
    882882                                        var id = String( ids[ counter++ ] );
    883883
    884                                         if ( isReserved( id ) || !/^(?:(?:[a-zA-Z$_][\w$_]*)|(?:\d+))$/.test( id ) )
     884                                        if ( isReserved( id ) || !/^(?:(?:[a-zA-Z$_][\w$_]*)|(?:0|[1-9]\d*))$/.test( id ) )
    885885                                                outString( id );
    886886                                        else
    887887                                                out( id );
  • test/test.js

     
    267267
    268268                [       "if(a){if(B)doB();}else if(c)doC();" ],
    269269
     270                [       "var a={'0':'0'};",
     271                        "var a={0:'0'};" ],
     272
     273                [       "var a={'1':'1'};",
     274                        "var a={1:'1'};" ],
     275
     276                [       "var a={'0123':'0123'};",
     277                        "var a={'0123':'0123'};" ],
     278
     279                [       "var a={'123':'123'};",
     280                        "var a={123:'123'};" ]
    270281        ];
    271282
    272283        var tests =
     
    292303        // Create the auto tests.
    293304        function createAutoTest( counter, source, expected )
    294305        {
    295                 tests[ 'autoTest' + ( counter + 1000 ).toString().substr( 1 ) ] = function()
     306                var test = tests[ 'autoTest' + ( counter + 1000 ).toString().substr( 1 ) ] = function()
    296307                {
    297308                        assertEquals( expected || source, CKPACKAGER.scriptCompressor.compress( source, true, null, true ) );
    298309                };
     310
     311                test.source = source;
     312                test.expected = expected || source;
    299313        }
    300314
    301315        for ( var i = 0 ; i < autoTests.length ; i++ )
     
    312326                try
    313327                {
    314328                        tests[ test ]();
    315                         print( 'PASSED: ' + test );
     329                        print( 'PASSED: (' + test + ') ' + tests[ test ].expected );
    316330                        passCount++;
    317331                }
    318332                catch ( error )
    319333                {
    320                         print( 'FAILED: ' + test );
     334                        print( 'FAILED: (' + test + ')' );
    321335
    322336                        if ( !error.expected )
    323337                                throw error;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy