CSE should deal with letrec
ClosedPublic

Authored by RolandSenn on Aug 2 2018, 12:16 PM.

Details

Summary

Add testcase for Trac #9441

Test Plan

make test TESTS="T9441a T9441b T9441c"

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
RolandSenn created this revision.Aug 2 2018, 12:16 PM
dfeuer requested changes to this revision.Aug 2 2018, 12:22 PM

I think there should also be one or two tests that don't rely on all the details of this particular case. To begin with, there should surely be a simple example of defining the same recursive function twice with different names.

This revision now requires changes to proceed.Aug 2 2018, 12:22 PM
RolandSenn updated this revision to Diff 17566.Aug 3 2018, 4:14 AM
RolandSenn edited the summary of this revision. (Show Details)Aug 3 2018, 4:16 AM
RolandSenn edited the test plan for this revision. (Show Details)
dfeuer accepted this revision.Aug 3 2018, 4:17 AM

Much better!

This revision is now accepted and ready to land.Aug 3 2018, 4:17 AM

@dfeuer: I added 2 additonal tests. The first as you suggested with the same recursive function twice with 2 different names. The second one with 2 different functions with the same subfunction in the where clause. I also renamed the existing test.
Please inform me, if you see other possibilites to improve the tests for Trac #9441

This revision was automatically updated to reflect the committed changes.

A bit late to the party, but this Makefile and grep business is really tricky later, and you can do all this in one line, see these for inspiration:

tests/stranal/should_compile/all.T:test('T10482',  [ grep_errmsg(r'wfoo.*Int#') ], compile, ['-dppr-cols=200 -ddump-simpl'])
tests/stranal/should_compile/all.T:test('T10482a', [ grep_errmsg(r'wf.*Int#') ],   compile, ['-dppr-cols=200 -ddump-simpl'])
tests/stranal/should_compile/all.T:test('T10694', [ grep_errmsg(r'Str=') ],   compile, ['-dppr-cols=200 -ddump-simpl'])
tests/stranal/should_compile/all.T:test('T11770', [ check_errmsg('OneShot') ], compile, ['-ddump-simpl'])

@nomeata Thanks for your comment!

you can do all this in one line

I have 3 different testcases with 3 different input modules and 2 different syslog outputs. Do you want me to put all 3 testcases into one single module?

see these for inspiration ... grep_errmsg() ... check_errmsg()

Your examples use predefined functions like grep_errmsg() and check_errmsg(). I agree, using predefined functions would be better. However, both functions compare with stderr. My tests compare with stdout. On https://ghc.haskell.org/trac/ghc/wiki/Building/RunningTests/Adding I could not find similar functions comparing with stdout.

Please advice!

@nomeata Thanks for your comment!

you can do all this in one line

I have 3 different testcases with 3 different input modules and 2 different syslog outputs. Do you want me to put all 3 testcases into one single module?

I meant one line per module :)

see these for inspiration ... grep_errmsg() ... check_errmsg()

Your examples use predefined functions like grep_errmsg() and check_errmsg(). I agree, using predefined functions would be better. However, both functions compare with stderr. My tests compare with stdout. On https://ghc.haskell.org/trac/ghc/wiki/Building/RunningTests/Adding I could not find similar functions comparing with stdout.

Please advice!

Look at driver/testlib.py to see what is available there, and how they work (although it is a bit obscure). The name may be misleading: grep_errmsg is, I believe, checking stdout, becaues that is where -ddump-simpl dumps to. At least, that is how these functoins are used so far:

tests/simplCore/should_compile/all.T:test('T14137', [ check_errmsg(r'thunk'), omit_ways(['profasm']) ], compile, ['-dsuppress-uniques -ddump-simpl'])
tests/simplCore/should_compile/all.T:test('T14186', [ only_ways(['optasm']), check_errmsg(r'bar = foo') ], compile, ['-ddump-simpl'])
tests/simplCore/should_compile/all.T:test('T14152', [ only_ways(['optasm']), check_errmsg(r'dead code') ], compile, ['-ddump-simpl'])
tests/simplCore/should_compile/all.T:                 only_ways(['optasm']), check_errmsg(r'dead code') ],
tests/stranal/should_compile/all.T:test('T11770', [ check_errmsg('OneShot') ], compile, ['-ddump-simpl'])
tests/stranal/should_compile/all.T:test('T10482',  [ grep_errmsg(r'wfoo.*Int#') ], compile, ['-dppr-cols=200 -ddump-simpl'])
tests/stranal/should_compile/all.T:test('T10482a', [ grep_errmsg(r'wf.*Int#') ],   compile, ['-dppr-cols=200 -ddump-simpl'])
tests/stranal/should_compile/all.T:test('T10694', [ grep_errmsg(r'Str=') ],   compile, ['-dppr-cols=200 -ddump-simpl'])

If you find that you cannot express what you want with grep_errmsg and check_errmsg (the latter is preferable, as it is simpler), feel entitled to extend driver/testlib.py! Also feel free to extend the wiki :-)

For the changes requested by nomeata see: https://phabricator.haskell.org/D5076