From 2b1e9b3f30817366b4f2d200b678c06650b52b5e Mon Sep 17 00:00:00 2001 From: "bclary%bclary.com" Date: Thu, 14 Sep 2006 12:31:31 +0000 Subject: [PATCH] JavaScript Tests - tweak compareSource for decompilation testing git-svn-id: svn://10.0.0.236/trunk@211685 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/tests/e4x/shell.js | 27 +++++++++++++++++++++++++-- mozilla/js/tests/js1_5/shell.js | 28 ++++++++++++++++++++++++++-- mozilla/js/tests/js1_6/shell.js | 28 ++++++++++++++++++++++++++-- mozilla/js/tests/js1_7/shell.js | 30 +++++++++++++++++++++++++++--- 4 files changed, 104 insertions(+), 9 deletions(-) diff --git a/mozilla/js/tests/e4x/shell.js b/mozilla/js/tests/e4x/shell.js index 19c8b259544..54401356971 100644 --- a/mozilla/js/tests/e4x/shell.js +++ b/mozilla/js/tests/e4x/shell.js @@ -340,15 +340,16 @@ JavaScriptOptions.prototype.reset = function () function compareSource(n, expect, actual) { + // compare source var expectP = expect. - replace(/([(){},.\[\]])/mg, ' $1 '). + replace(/([(){},.:\[\]])/mg, ' $1 '). replace(/(\w+)/mg, ' $1 '). replace(/<(\/)? (\w+) (\/)?>/mg, '<$1$2$3>'). replace(/\s+/mg, ' '). replace(/new (\w+)\s*\(\s*\)/mg, 'new $1'); var actualP = actual. - replace(/([(){},.\[\]])/mg, ' $1 '). + replace(/([(){},.:\[\]])/mg, ' $1 '). replace(/(\w+)/mg, ' $1 '). replace(/<(\/)? (\w+) (\/)?>/mg, '<$1$2$3>'). replace(/\s+/mg, ' '). @@ -358,4 +359,26 @@ function compareSource(n, expect, actual) print('actual:\n' + actualP); TEST(n, expectP, actualP); + + // actual must be compilable if expect is? + try + { + var expectCompile = 'No Error'; + var actualCompile; + + eval(expect); + try + { + eval(actual); + actualCompile = 'No Error'; + } + catch(ex1) + { + actualCompile = ex1 + ''; + } + TEST(n, expectCompile, actualCompile); + } + catch(ex) + { + } } diff --git a/mozilla/js/tests/js1_5/shell.js b/mozilla/js/tests/js1_5/shell.js index 8d77bb679b0..6a08be9dc26 100644 --- a/mozilla/js/tests/js1_5/shell.js +++ b/mozilla/js/tests/js1_5/shell.js @@ -482,15 +482,16 @@ JavaScriptOptions.prototype.reset = function () function compareSource(expect, actual, summary) { + // compare source var expectP = expect. - replace(/([(){},.\[\]])/mg, ' $1 '). + replace(/([(){},.:\[\]])/mg, ' $1 '). replace(/(\w+)/mg, ' $1 '). replace(/<(\/)? (\w+) (\/)?>/mg, '<$1$2$3>'). replace(/\s+/mg, ' '). replace(/new (\w+)\s*\(\s*\)/mg, 'new $1'); var actualP = actual. - replace(/([(){},.\[\]])/mg, ' $1 '). + replace(/([(){},.:\[\]])/mg, ' $1 '). replace(/(\w+)/mg, ' $1 '). replace(/<(\/)? (\w+) (\/)?>/mg, '<$1$2$3>'). replace(/\s+/mg, ' '). @@ -500,4 +501,27 @@ function compareSource(expect, actual, summary) writeLineToLog('actual:\n' + actualP); reportCompare(true, expectP === actualP, summary); + + // actual must be compilable if expect is? + try + { + var expectCompile = 'No Error'; + var actualCompile; + + eval(expect); + try + { + eval(actual); + actualCompile = 'No Error'; + } + catch(ex1) + { + actualCompile = ex1 + ''; + } + reportCompare(expectCompile, actualCompile, + summary + ': compile actual'); + } + catch(ex) + { + } } diff --git a/mozilla/js/tests/js1_6/shell.js b/mozilla/js/tests/js1_6/shell.js index 28502ea2476..fd82e87e32f 100755 --- a/mozilla/js/tests/js1_6/shell.js +++ b/mozilla/js/tests/js1_6/shell.js @@ -483,15 +483,16 @@ JavaScriptOptions.prototype.reset = function () function compareSource(expect, actual, summary) { + // compare source var expectP = expect. - replace(/([(){},.\[\]])/mg, ' $1 '). + replace(/([(){},.:\[\]])/mg, ' $1 '). replace(/(\w+)/mg, ' $1 '). replace(/<(\/)? (\w+) (\/)?>/mg, '<$1$2$3>'). replace(/\s+/mg, ' '). replace(/new (\w+)\s*\(\s*\)/mg, 'new $1'); var actualP = actual. - replace(/([(){},.\[\]])/mg, ' $1 '). + replace(/([(){},.:\[\]])/mg, ' $1 '). replace(/(\w+)/mg, ' $1 '). replace(/<(\/)? (\w+) (\/)?>/mg, '<$1$2$3>'). replace(/\s+/mg, ' '). @@ -501,4 +502,27 @@ function compareSource(expect, actual, summary) writeLineToLog('actual:\n' + actualP); reportCompare(true, expectP === actualP, summary); + + // actual must be compilable if expect is? + try + { + var expectCompile = 'No Error'; + var actualCompile; + + eval(expect); + try + { + eval(actual); + actualCompile = 'No Error'; + } + catch(ex1) + { + actualCompile = ex1 + ''; + } + reportCompare(expectCompile, actualCompile, + summary + ': compile actual'); + } + catch(ex) + { + } } diff --git a/mozilla/js/tests/js1_7/shell.js b/mozilla/js/tests/js1_7/shell.js index faccaaaca67..bb50cbc9d19 100644 --- a/mozilla/js/tests/js1_7/shell.js +++ b/mozilla/js/tests/js1_7/shell.js @@ -489,15 +489,16 @@ JavaScriptOptions.prototype.reset = function () function compareSource(expect, actual, summary) { + // compare source var expectP = expect. - replace(/([(){},.\[\]])/mg, ' $1 '). + replace(/([(){},.:\[\]])/mg, ' $1 '). replace(/(\w+)/mg, ' $1 '). replace(/<(\/)? (\w+) (\/)?>/mg, '<$1$2$3>'). replace(/\s+/mg, ' '). replace(/new (\w+)\s*\(\s*\)/mg, 'new $1'); var actualP = actual. - replace(/([(){},.\[\]])/mg, ' $1 '). + replace(/([(){},.:\[\]])/mg, ' $1 '). replace(/(\w+)/mg, ' $1 '). replace(/<(\/)? (\w+) (\/)?>/mg, '<$1$2$3>'). replace(/\s+/mg, ' '). @@ -506,5 +507,28 @@ function compareSource(expect, actual, summary) writeLineToLog('expect:\n' + expectP); writeLineToLog('actual:\n' + actualP); - reportCompare(true, expectP === actualP, summary); + reportCompare(true, expectP === actualP, summary + ': compare source'); + + // actual must be compilable if expect is? + try + { + var expectCompile = 'No Error'; + var actualCompile; + + eval(expect); + try + { + eval(actual); + actualCompile = 'No Error'; + } + catch(ex1) + { + actualCompile = ex1 + ''; + } + reportCompare(expectCompile, actualCompile, + summary + ': compile actual'); + } + catch(ex) + { + } }