Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
davjam
GHC
Commits
610d0283
Commit
610d0283
authored
3 years ago
by
Matthew Craven
Committed by
Marge Bot
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add a test for the bracketing in rules for (^)
parent
7da90ae3
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
testsuite/tests/lib/base/T19569.hs
+56
-0
56 additions, 0 deletions
testsuite/tests/lib/base/T19569.hs
testsuite/tests/lib/base/all.T
+1
-0
1 addition, 0 deletions
testsuite/tests/lib/base/all.T
with
57 additions
and
0 deletions
testsuite/tests/lib/base/T19569.hs
0 → 100644
+
56
−
0
View file @
610d0283
-- This program is meant to compare the bracketing produced by the
-- actual implementation of (^) with the bracketing in the RHS of its
-- rewrite rules for known small powers, and complains if they disagree.
{-# OPTIONS_GHC -O -Wno-missing-methods #-}
module
Main
where
import
Control.Monad
import
Data.Typeable
import
Numeric.Natural
import
Text.Printf
data
MulTree
=
X
|
FromInteger
Integer
|
Mul
MulTree
MulTree
deriving
(
Eq
,
Show
)
instance
Num
MulTree
where
fromInteger
=
FromInteger
(
*
)
=
Mul
opaquePow
::
(
Num
a
,
Integral
b
)
=>
a
->
b
->
a
{-# NOINLINE opaquePow #-}
opaquePow
k
e
=
k
^
e
checkRules
::
forall
expTy
.
(
Integral
expTy
,
Show
expTy
,
Typeable
expTy
)
=>
expTy
->
IO
()
{-# INLINE checkRules #-}
checkRules
_
=
let
checkOne
::
expTy
->
IO
()
{-# INLINE checkOne #-}
checkOne
e
=
when
(
X
^
e
/=
opaquePow
X
e
)
(
reportProblem
(
X
^
e
)
e
)
reportProblem
::
MulTree
->
expTy
->
IO
()
reportProblem
wrongVal
e
=
do
printf
"Problem with exponent (%s :: %s)
\n
"
(
show
e
)
(
show
$
typeOf
e
)
printf
" Expected: %s
\n
"
(
show
$
opaquePow
X
e
)
printf
" Actual: %s
\n
"
(
show
wrongVal
)
in
do
checkOne
0
checkOne
1
checkOne
2
checkOne
3
checkOne
4
checkOne
5
checkOne
6
checkOne
7
checkOne
8
checkOne
9
checkOne
10
main
::
IO
()
main
=
do
checkRules
(
0
::
Integer
)
checkRules
(
0
::
Natural
)
checkRules
(
0
::
Int
)
checkRules
(
0
::
Word
)
This diff is collapsed.
Click to expand it.
testsuite/tests/lib/base/all.T
+
1
−
0
View file @
610d0283
...
...
@@ -6,3 +6,4 @@ test('T17310', normal, compile, [''])
test
('
T19691
',
normal
,
compile
,
[''])
test
('
executablePath
',
extra_run_opts
(
config
.
os
),
compile_and_run
,
[''])
test
('
T17472
',
normal
,
compile_and_run
,
[''])
test
('
T19569
',
expect_broken
(
19569
),
compile_and_run
,
[''])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment