mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix bug 383174: Add new reportMatch function in shell.jsr=bclary@bclary.com
This commit is contained in:
parent
503fe8c628
commit
40714a5a6e
@ -65,7 +65,7 @@ function test()
|
||||
}
|
||||
reportCompare(expect, actual, summary + ': function() {x = 12 + yield;}');
|
||||
|
||||
expect = 'SyntaxError: yield expression must be parenthesized';
|
||||
expect = /SyntaxError: yield expression must be parenthesized/;
|
||||
try
|
||||
{
|
||||
eval('(function () {foo(yield)})');
|
||||
@ -75,7 +75,7 @@ function test()
|
||||
{
|
||||
actual = ex + '';
|
||||
}
|
||||
reportCompare(expect, actual, summary + ': function () {foo(yield)}');
|
||||
reportMatch(expect, actual, summary + ': function () {foo(yield)}');
|
||||
|
||||
expect = 'SyntaxError: syntax error';
|
||||
try
|
||||
@ -89,7 +89,7 @@ function test()
|
||||
}
|
||||
reportCompare(expect, actual, summary + ': function() {x = 12 + yield 42}');
|
||||
|
||||
expect = 'SyntaxError: yield expression must be parenthesized';
|
||||
expect = /SyntaxError: yield expression must be parenthesized/;
|
||||
try
|
||||
{
|
||||
eval('(function (){foo(yield 42)})');
|
||||
@ -99,10 +99,9 @@ function test()
|
||||
{
|
||||
actual = ex + '';
|
||||
}
|
||||
reportCompare(expect, actual, summary + ': function (){foo(yield 42)}');
|
||||
reportMatch(expect, actual, summary + ': function (){foo(yield 42)}');
|
||||
|
||||
expect = 'No Error';
|
||||
|
||||
try
|
||||
{
|
||||
eval('(function() {x = 12 + (yield);})');
|
||||
|
@ -59,7 +59,7 @@ function test()
|
||||
yield 1;
|
||||
}
|
||||
|
||||
expect = true;
|
||||
expect = /TypeError.*[aA]lready executing generator/;
|
||||
try
|
||||
{
|
||||
iter = gen();
|
||||
@ -69,10 +69,9 @@ function test()
|
||||
catch(ex)
|
||||
{
|
||||
print(ex + '');
|
||||
actual = (ex instanceof TypeError) && (ex + '').indexOf(' already executing generator') != -1;
|
||||
actual = ex + '';
|
||||
}
|
||||
|
||||
reportCompare(expect, actual, summary);
|
||||
reportMatch(expect, actual, summary);
|
||||
|
||||
exitFunc ('test');
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ function test()
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
expect = 'TypeError: [].z is not a function';
|
||||
expect = /TypeError:.*(is not a function|Cannot find function).*/;
|
||||
actual = '';
|
||||
try
|
||||
{
|
||||
@ -63,7 +63,7 @@ function test()
|
||||
{
|
||||
actual = ex + '';
|
||||
}
|
||||
reportCompare(expect, actual, summary);
|
||||
reportMatch(expect, actual, summary);
|
||||
|
||||
exitFunc ('test');
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ function test()
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
expect = 'SyntaxError: yield expression must be parenthesized';
|
||||
expect = /SyntaxError: yield expression must be parenthesized/;
|
||||
try
|
||||
{
|
||||
eval('function f() { yield g(yield 1, 2) };');
|
||||
@ -63,7 +63,7 @@ function test()
|
||||
actual = ex + '';
|
||||
}
|
||||
|
||||
reportCompare(expect, actual, summary);
|
||||
reportMatch(expect, actual, summary);
|
||||
|
||||
exitFunc ('test');
|
||||
}
|
||||
|
@ -52,9 +52,8 @@ function test()
|
||||
enterFunc ('test');
|
||||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
expect = 'TypeError: anonymous generator function returns a value';
|
||||
|
||||
|
||||
expect = /TypeError: anonymous generator function returns a value/;
|
||||
try
|
||||
{
|
||||
var gen = eval('(function() { { return 5; } yield 3; })');
|
||||
@ -64,8 +63,7 @@ function test()
|
||||
{
|
||||
actual = ex + '';
|
||||
}
|
||||
|
||||
reportCompare(expect, actual, summary);
|
||||
reportMatch(expect, actual, summary);
|
||||
|
||||
exitFunc ('test');
|
||||
}
|
||||
|
@ -232,8 +232,7 @@ function toPrinted(value)
|
||||
* type) report a failure. If description is provided, include it in the
|
||||
* failure report.
|
||||
*/
|
||||
function reportCompare (expected, actual, description)
|
||||
{
|
||||
function reportCompare (expected, actual, description) {
|
||||
var expected_t = typeof expected;
|
||||
var actual_t = typeof actual;
|
||||
var output = "";
|
||||
@ -248,8 +247,8 @@ function reportCompare (expected, actual, description)
|
||||
}
|
||||
else if (VERBOSE)
|
||||
{
|
||||
printStatus ("Expected type '" + actual_t + "' matched actual " +
|
||||
"type '" + expected_t + "'");
|
||||
printStatus ("Expected type '" + expected_t + "' matched actual " +
|
||||
"type '" + actual_t + "'");
|
||||
}
|
||||
|
||||
if (expected != actual)
|
||||
@ -259,8 +258,8 @@ function reportCompare (expected, actual, description)
|
||||
}
|
||||
else if (VERBOSE)
|
||||
{
|
||||
printStatus ("Expected value '" + toPrinted(actual) +
|
||||
"' matched actual value '" + toPrinted(expected) + "'");
|
||||
printStatus ("Expected value '" + toPrinted(expected) +
|
||||
"' matched actual value '" + toPrinted(actual) + "'");
|
||||
}
|
||||
|
||||
if (typeof description == "undefined")
|
||||
@ -281,6 +280,61 @@ function reportCompare (expected, actual, description)
|
||||
return testcase.passed;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attempt to match a regular expression describing the result to
|
||||
* the actual result, if they differ (in value and/or
|
||||
* type) report a failure. If description is provided, include it in the
|
||||
* failure report.
|
||||
*/
|
||||
function reportMatch (expectedRegExp, actual, description) {
|
||||
var expected_t = "string";
|
||||
var actual_t = typeof actual;
|
||||
var output = "";
|
||||
|
||||
if ((VERBOSE) && (typeof description != "undefined"))
|
||||
printStatus ("Comparing '" + description + "'");
|
||||
|
||||
if (expected_t != actual_t)
|
||||
{
|
||||
output += "Type mismatch, expected type " + expected_t +
|
||||
", actual type " + actual_t + " ";
|
||||
}
|
||||
else if (VERBOSE)
|
||||
{
|
||||
printStatus ("Expected type '" + expected_t + "' matched actual " +
|
||||
"type '" + actual_t + "'");
|
||||
}
|
||||
|
||||
var matches = expectedRegExp.test(actual);
|
||||
if (!matches)
|
||||
{
|
||||
output += "Expected match to '" + toPrinted(expectedRegExp) +
|
||||
"', Actual value '" + toPrinted(actual) + "' ";
|
||||
}
|
||||
else if (VERBOSE)
|
||||
{
|
||||
printStatus ("Expected match to '" + toPrinted(expectedRegExp) +
|
||||
"' matched actual value '" + toPrinted(actual) + "'");
|
||||
}
|
||||
|
||||
if (typeof description == "undefined")
|
||||
description = '';
|
||||
|
||||
var testcase = new TestCase(gTestfile, description, true, matches);
|
||||
testcase.reason = output;
|
||||
|
||||
if (testcase.passed)
|
||||
{
|
||||
print('PASSED! ' + description);
|
||||
}
|
||||
else
|
||||
{
|
||||
reportFailure (output);
|
||||
}
|
||||
|
||||
return testcase.passed;
|
||||
}
|
||||
|
||||
/*
|
||||
* Puts funcName at the top of the call stack. This stack is used to show
|
||||
* a function-reported-from field when reporting failures.
|
||||
@ -491,7 +545,7 @@ function compareSource(expect, actual, summary)
|
||||
actualCompile = ex1 + '';
|
||||
}
|
||||
reportCompare(expectCompile, actualCompile,
|
||||
summary + ': compile actual');
|
||||
summary + ': compile actual');
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user