Skip to content

Commit

Permalink
tests: skip comparing unique numbers generated by the compiler that c…
Browse files Browse the repository at this point in the history
…reep into error message
  • Loading branch information
rainers committed May 1, 2015
1 parent 1f97d40 commit 7334038
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
21 changes: 20 additions & 1 deletion test/d_do_test.d
Expand Up @@ -396,6 +396,25 @@ bool collectExtraSources (in string input_dir, in string output_dir, in string[]
return true;
}

// compare output string to reference string, but ignore places
// marked by $n$ that contain compiler generated unique numbers
bool compareOutput(string output, string refoutput)
{
for ( ; ; )
{
auto pos = refoutput.indexOf("$n$");
if (pos < 0)
return refoutput == output;
if (output.length < pos)
return false;
if (refoutput[0..pos] != output[0..pos])
return false;
refoutput = refoutput[pos + 3 ..$];
output = output[pos..$];
munch(output, "0123456789");
}
}

int main(string[] args)
{
if (args.length != 4)
Expand Down Expand Up @@ -568,7 +587,7 @@ int main(string[] args)

if (testArgs.compileOutput !is null)
{
enforce(compile_output == testArgs.compileOutput,
enforce(compareOutput(compile_output, testArgs.compileOutput),
"\nexpected:\n----\n"~testArgs.compileOutput~"\n----\nactual:\n----\n"~compile_output~"\n----\n");
}

Expand Down
8 changes: 4 additions & 4 deletions test/fail_compilation/fail7848.d
Expand Up @@ -3,11 +3,11 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail7848.d(35): Error: pure function 'fail7848.C.__unittestL33_1' cannot call impure function 'fail7848.func'
fail_compilation/fail7848.d(35): Error: safe function 'fail7848.C.__unittestL33_1' cannot call system function 'fail7848.func'
fail_compilation/fail7848.d(35): Error: @nogc function 'fail7848.C.__unittestL33_1' cannot call non-@nogc function 'fail7848.func'
fail_compilation/fail7848.d(35): Error: pure function 'fail7848.C.__unittestL33_$n$' cannot call impure function 'fail7848.func'
fail_compilation/fail7848.d(35): Error: safe function 'fail7848.C.__unittestL33_$n$' cannot call system function 'fail7848.func'
fail_compilation/fail7848.d(35): Error: @nogc function 'fail7848.C.__unittestL33_$n$' cannot call non-@nogc function 'fail7848.func'
fail_compilation/fail7848.d(35): Error: 'fail7848.func' is not nothrow
fail_compilation/fail7848.d(33): Error: function 'fail7848.C.__unittestL33_1' is nothrow yet may throw
fail_compilation/fail7848.d(33): Error: function 'fail7848.C.__unittestL33_$n$' is nothrow yet may throw
fail_compilation/fail7848.d(40): Error: pure function 'fail7848.C.__invariant2' cannot call impure function 'fail7848.func'
fail_compilation/fail7848.d(40): Error: safe function 'fail7848.C.__invariant2' cannot call system function 'fail7848.func'
fail_compilation/fail7848.d(40): Error: @nogc function 'fail7848.C.__invariant2' cannot call non-@nogc function 'fail7848.func'
Expand Down
4 changes: 2 additions & 2 deletions test/fail_compilation/fail_casting.d
Expand Up @@ -147,8 +147,8 @@ void test14154()
/*
TEST_OUTPUT:
---
fail_compilation/fail_casting.d(179): Error: cannot cast expression __tup3.__expand_field_0 of type int to object.Object
fail_compilation/fail_casting.d(179): Error: cannot cast expression __tup3.__expand_field_1 of type int to object.Object
fail_compilation/fail_casting.d(179): Error: cannot cast expression __tup$n$.__expand_field_0 of type int to object.Object
fail_compilation/fail_casting.d(179): Error: cannot cast expression __tup$n$.__expand_field_1 of type int to object.Object
---
*/
alias TypeTuple14093(T...) = T;
Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/ice14424.d
Expand Up @@ -2,7 +2,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice14424.d(12): Error: tuple has no effect in expression (tuple(__unittestL3_1))
fail_compilation/ice14424.d(12): Error: tuple has no effect in expression (tuple(__unittestL3_$n$))
---
*/

Expand Down

0 comments on commit 7334038

Please sign in to comment.