Import hs-plugins cvs
This commit is contained in:
37
examples/printf/000/Main.hs
Normal file
37
examples/printf/000/Main.hs
Normal file
@ -0,0 +1,37 @@
|
||||
import Printf
|
||||
|
||||
main = do printf "%d\n" $> (42::Int) ! []
|
||||
printf "%u\n" $> (42::Int) ! []
|
||||
printf "0%o\n" $> (42::Int) ! []
|
||||
printf "0x%x\n" $> (42::Int) ! []
|
||||
printf "0x%X\n" $> (42::Int) ! []
|
||||
|
||||
printf "%e\n" $> (42.1234 :: Double) ! []
|
||||
printf "%E\n" $> (42.1234 :: Double) ! []
|
||||
printf "%g\n" $> (42.1234 :: Double) ! []
|
||||
printf "%G\n" $> (42.1234 :: Double) ! []
|
||||
printf "%f\n" $> (42.1234 :: Double) ! []
|
||||
|
||||
printf "%c:%c:%c\n" $> 'a' ! 'b' ! 'c' ! []
|
||||
printf "%s\n" $> "printf" ! []
|
||||
|
||||
printf "%+d\n" $> (42::Int) ! []
|
||||
printf "%+0d\n" $> (42::Int) ! []
|
||||
printf "%0+d\n" $> (42::Int) ! []
|
||||
printf "%10d\n" $> (42::Int) ! []
|
||||
printf "%-010d\n" $> (42::Int) ! []
|
||||
printf "%-010.2d\n" $> (42::Int) ! []
|
||||
|
||||
printf "%+f\n" $> (42.1234 :: Double) ! []
|
||||
printf "%+0f\n" $> (42.1234 :: Double) ! []
|
||||
printf "%0+f\n" $> (42.1234 :: Double) ! []
|
||||
printf "%10f\n" $> (42.1234 :: Double) ! []
|
||||
printf "%-010f\n" $> (42.1234 :: Double) ! []
|
||||
printf "%-010.2f\n" $> (42.1234 :: Double) ! []
|
||||
|
||||
printf "%10s\n" $> "printf" ! []
|
||||
printf "%-10s\n" $> "printf" ! []
|
||||
printf "%10.2s\n" $> "printf" ! []
|
||||
printf "%2.10s\n" $> "printf" ! []
|
||||
printf "%-2.10s\n" $> "printf" ! []
|
||||
printf "%-10.2s\n" $> "printf" ! []
|
2
examples/printf/000/Makefile
Normal file
2
examples/printf/000/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
TOP=../../..
|
||||
include ../../eval.mk
|
30
examples/printf/000/expected
Normal file
30
examples/printf/000/expected
Normal file
@ -0,0 +1,30 @@
|
||||
42
|
||||
42
|
||||
052
|
||||
0x2a
|
||||
0x2A
|
||||
4.212340e1
|
||||
4.212340E1
|
||||
42.123400
|
||||
42.123400
|
||||
42.123400
|
||||
a:b:c
|
||||
printf
|
||||
+42
|
||||
+42
|
||||
+42
|
||||
42
|
||||
42
|
||||
42
|
||||
+42.123400
|
||||
+42.123400
|
||||
+42.123400
|
||||
42.123400
|
||||
42.123400
|
||||
42.12
|
||||
printf
|
||||
printf
|
||||
pr
|
||||
printf
|
||||
printf
|
||||
pr
|
36
examples/printf/000/printf.sh
Normal file
36
examples/printf/000/printf.sh
Normal file
@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
printf "%d\n" 42
|
||||
printf "%u\n" 42
|
||||
printf "0%o\n" 42
|
||||
printf "0x%x\n" 42
|
||||
printf "0x%X\n" 42
|
||||
|
||||
printf "%e\n" 42.1234
|
||||
printf "%E\n" 42.1234
|
||||
printf "%g\n" 42.1234
|
||||
printf "%G\n" 42.1234
|
||||
printf "%f\n" 42.1234
|
||||
|
||||
printf "%c:%c:%c\n" 'a' 'b' 'c'
|
||||
printf "%s\n" "printf"
|
||||
|
||||
printf "%+d\n" 42
|
||||
printf "%+0d\n" 42
|
||||
printf "%0+d\n" 42
|
||||
printf "%10d\n" 42
|
||||
printf "%-010d\n" 42
|
||||
printf "%-010.2d\n" 42
|
||||
|
||||
printf "%+f\n" 42.1234
|
||||
printf "%+0f\n" 42.1234
|
||||
printf "%0+f\n" 42.1234
|
||||
printf "%10f\n" 42.1234
|
||||
printf "%-010f\n" 42.1234
|
||||
printf "%-010.2f\n" 42.1234
|
||||
|
||||
printf "%10s\n" "printf"
|
||||
printf "%-10s\n" "printf"
|
||||
printf "%10.2s\n" "printf"
|
||||
printf "%2.10s\n" "printf"
|
||||
printf "%-2.10s\n" "printf"
|
||||
printf "%-10.2s\n" "printf"
|
13
examples/printf/001/Main.hs
Normal file
13
examples/printf/001/Main.hs
Normal file
@ -0,0 +1,13 @@
|
||||
import Printf
|
||||
|
||||
main = do
|
||||
printf "%d\n" $> (42 :: Int) ! []
|
||||
printf "0x%X\n" $> (42 :: Int) ! []
|
||||
printf "%f\n" $> (42.1234 :: Double) ! []
|
||||
printf "%c:%c:%c\n" $> 'a' ! 'b' ! 'c' ! []
|
||||
printf "%s\n" $> "haskell" ! []
|
||||
printf "%-010.4d\n" $> (42 :: Int) ! []
|
||||
printf "%010.4f\n" $> (42.1234 :: Double) ! []
|
||||
printf "%10.4s\n" $> (show (7 :: Int)) ! []
|
||||
printf "%-10.4s\n" $> "haskell" ! []
|
||||
|
2
examples/printf/001/Makefile
Normal file
2
examples/printf/001/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
TOP=../../..
|
||||
include ../../eval.mk
|
9
examples/printf/001/expected
Normal file
9
examples/printf/001/expected
Normal file
@ -0,0 +1,9 @@
|
||||
42
|
||||
0x2A
|
||||
42.123400
|
||||
a:b:c
|
||||
haskell
|
||||
42
|
||||
00042.1234
|
||||
7
|
||||
hask
|
12
examples/printf/002/Main.hs
Normal file
12
examples/printf/002/Main.hs
Normal file
@ -0,0 +1,12 @@
|
||||
import Printf
|
||||
import Control.Exception ( evaluate )
|
||||
|
||||
main = do
|
||||
fn <- evaluate $! printf "%10.4f\n"
|
||||
fn $> (10.0 :: Double) ! []
|
||||
fn $> (-10.0 :: Double) ! []
|
||||
fn $> (10.1010 :: Double) ! []
|
||||
fn $> (0.0 :: Double) ! []
|
||||
fn $> (0.987654321 :: Double) ! []
|
||||
fn $> (987654321 :: Double) ! []
|
||||
fn $> (-987654321 :: Double) ! []
|
2
examples/printf/002/Makefile
Normal file
2
examples/printf/002/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
TOP=../../..
|
||||
include ../../eval.mk
|
7
examples/printf/002/expected
Normal file
7
examples/printf/002/expected
Normal file
@ -0,0 +1,7 @@
|
||||
10.0000
|
||||
-10.0000
|
||||
10.1010
|
||||
0.0000
|
||||
0.9877
|
||||
987654321.0000
|
||||
-987654321.0000
|
3
examples/printf/should_fail_000/Main.hs
Normal file
3
examples/printf/should_fail_000/Main.hs
Normal file
@ -0,0 +1,3 @@
|
||||
import Printf
|
||||
|
||||
main = printf "%x\n" $> "badstring" ! []
|
2
examples/printf/should_fail_000/Makefile
Normal file
2
examples/printf/should_fail_000/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
TOP=../../..
|
||||
include ../../eval.mk
|
3
examples/printf/should_fail_000/expected
Normal file
3
examples/printf/should_fail_000/expected
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
Fail: Type error in dynamic application.
|
||||
Can't apply function <Int -> [Char]> to argument <[Char]>
|
2
examples/printf/should_fail_000/expected.604
Normal file
2
examples/printf/should_fail_000/expected.604
Normal file
@ -0,0 +1,2 @@
|
||||
a.out: Type error in dynamic application.
|
||||
Can't apply function <Int -> [Char]> to argument <[Char]>
|
13
examples/printf/should_fail_001/Main.hs
Normal file
13
examples/printf/should_fail_001/Main.hs
Normal file
@ -0,0 +1,13 @@
|
||||
import Printf
|
||||
|
||||
main = do
|
||||
printf "%d\n" $> (42 :: Int) ! []
|
||||
printf "0x%X\n" $> (42 :: Int) ! []
|
||||
printf "%f\n" $> (42.1234 :: Double) ! []
|
||||
printf "%c:%c:%c\n" $> 'a' ! 'b' ! 'c' ! []
|
||||
printf "%s\n" $> "haskell" ! []
|
||||
printf "%-010.4d\n" $> (42 :: Int) ! []
|
||||
printf "%010.4f\n" $> (42.1234 :: Double) ! []
|
||||
printf "%10.4s\n" $> (7 :: Int)! []
|
||||
printf "%-10.4s\n" $> "haskell" ! []
|
||||
|
2
examples/printf/should_fail_001/Makefile
Normal file
2
examples/printf/should_fail_001/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
TOP=../../..
|
||||
include ../../eval.mk
|
10
examples/printf/should_fail_001/expected
Normal file
10
examples/printf/should_fail_001/expected
Normal file
@ -0,0 +1,10 @@
|
||||
42
|
||||
0x2A
|
||||
42.123400
|
||||
a:b:c
|
||||
haskell
|
||||
42
|
||||
00042.1234
|
||||
|
||||
Fail: Type error in dynamic application.
|
||||
Can't apply function <[Char] -> [Char]> to argument <Int>
|
9
examples/printf/should_fail_001/expected.604
Normal file
9
examples/printf/should_fail_001/expected.604
Normal file
@ -0,0 +1,9 @@
|
||||
42
|
||||
0x2A
|
||||
42.123400
|
||||
a:b:c
|
||||
haskell
|
||||
42
|
||||
00042.1234
|
||||
a.out: Type error in dynamic application.
|
||||
Can't apply function <[Char] -> [Char]> to argument <Int>
|
Reference in New Issue
Block a user