Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/Language/PureScript/Backend/Lua/Golden/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ spec = do
, "--std min"
, "--no-color"
, "--no-unused" -- TODO: harden eventually
, "--no-redefined" -- generated code shadows freely (e.g.
-- inlined library fallbacks reusing a parameter name)
, "--no-max-line-length"
, "--formatter plain"
, "--allow-defined"
Expand Down
48 changes: 48 additions & 0 deletions test/ps/golden/Golden/StringCodePoints/Test.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
-- Exercises Data.String.CodePoints end to end on the released package set
-- (Unisay/purescript-lua-strings v6.2.0). The test string mixes UTF-8 widths
-- 1..4: 'a' (1 byte), 'é' (2), 'Я' (2, Cyrillic), '𝐀' (4, astral), 'z' (1).
-- Output is all Ints/Bools via fromEnum so the golden stays ASCII and does
-- not depend on how strings are shown.
module Golden.StringCodePoints.Test where

import Prelude

import Data.Enum (fromEnum, toEnum)
import Data.Maybe (fromJust)
import Data.String.CodePoints (CodePoint)
import Data.String.CodePoints as SCP
import Data.String.CodeUnits as SCU
import Effect (Effect)
import Effect.Console (logShow)
import Partial.Unsafe (unsafePartial)

str :: String
str = "aéЯ𝐀z"

codes :: String -> Array Int
codes = map fromEnum <<< SCP.toCodePointArray

main :: Effect Unit
main = do
-- decode every code point
logShow (codes str)
-- code-point length vs byte length
logShow (SCP.length str)
logShow (SCU.length str)
-- take/drop split on a code-point boundary (not mid-multibyte)
logShow (codes (SCP.take 2 str))
logShow (codes (SCP.drop 2 str))
-- indexing, including the astral code point and out of range
logShow (fromEnum <$> SCP.codePointAt 0 str)
logShow (fromEnum <$> SCP.codePointAt 3 str)
logShow (fromEnum <$> SCP.codePointAt 5 str)
-- uncons head and the decoded tail
logShow ((fromEnum <<< _.head) <$> SCP.uncons str)
logShow ((codes <<< _.tail) <$> SCP.uncons str)
-- encode round-trips back to the original bytes
logShow (SCP.fromCodePointArray (SCP.toCodePointArray str) == str)
-- singleton of an astral code point decodes back to itself
logShow (codes (SCP.singleton (cp 0x1D400)))

cp :: Int -> CodePoint
cp = unsafePartial fromJust <<< toEnum
6 changes: 3 additions & 3 deletions test/ps/output/Golden.ArrayOfUnits.Test/golden.ir
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ UberModule
( QName
{ qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign"
}, ForeignImport Nothing
( ModuleName "Data.Unit" ) ".spago/prelude/v7.2.0/src/Data/Unit.purs"
( ModuleName "Data.Unit" ) ".spago/prelude/v7.2.1/src/Data/Unit.purs"
[ ( Just Always, Name "unit" ) ]
), Standalone
( QName
{ qnameModuleName = ModuleName "Data.Semiring", qnameName = Name "foreign"
}, ForeignImport Nothing
( ModuleName "Data.Semiring" ) ".spago/prelude/v7.2.0/src/Data/Semiring.purs"
( ModuleName "Data.Semiring" ) ".spago/prelude/v7.2.1/src/Data/Semiring.purs"
[ ( Nothing, Name "intAdd" ), ( Nothing, Name "intMul" ) ]
), Standalone
( QName
Expand Down Expand Up @@ -552,7 +552,7 @@ UberModule
[
( PropName "show", ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Data.Show" ) ".spago/prelude/v7.2.0/src/Data/Show.purs"
( ModuleName "Data.Show" ) ".spago/prelude/v7.2.1/src/Data/Show.purs"
[ ( Nothing, Name "showIntImpl" ) ]
)
( PropName "showIntImpl" )
Expand Down
6 changes: 3 additions & 3 deletions test/ps/output/Golden.BugListGenericEq.Test/golden.ir
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ UberModule
( QName
{ qnameModuleName = ModuleName "Data.HeytingAlgebra", qnameName = Name "foreign"
}, ForeignImport Nothing
( ModuleName "Data.HeytingAlgebra" ) ".spago/prelude/v7.2.0/src/Data/HeytingAlgebra.purs"
( ModuleName "Data.HeytingAlgebra" ) ".spago/prelude/v7.2.1/src/Data/HeytingAlgebra.purs"
[ ( Nothing, Name "boolConj" ), ( Nothing, Name "boolDisj" ), ( Nothing, Name "boolNot" ) ]
), Standalone
( QName
Expand Down Expand Up @@ -120,7 +120,7 @@ UberModule
( Nothing, Name "get", App Nothing
( ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Record.Unsafe" ) ".spago/prelude/v7.2.0/src/Record/Unsafe.purs"
( ModuleName "Record.Unsafe" ) ".spago/prelude/v7.2.1/src/Record/Unsafe.purs"
[ ( Nothing, Name "unsafeGet" ) ]
)
( PropName "unsafeGet" )
Expand Down Expand Up @@ -883,7 +883,7 @@ UberModule
[
( PropName "eq", ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Data.Eq" ) ".spago/prelude/v7.2.0/src/Data/Eq.purs"
( ModuleName "Data.Eq" ) ".spago/prelude/v7.2.1/src/Data/Eq.purs"
[ ( Nothing, Name "eqIntImpl" ) ]
)
( PropName "eqIntImpl" )
Expand Down
6 changes: 3 additions & 3 deletions test/ps/output/Golden.CharLiterals.Test/golden.ir
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ UberModule
[
( PropName "eq", ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Data.Eq" ) ".spago/prelude/v7.2.0/src/Data/Eq.purs"
( ModuleName "Data.Eq" ) ".spago/prelude/v7.2.1/src/Data/Eq.purs"
[ ( Nothing, Name "eqCharImpl" ) ]
)
( PropName "eqCharImpl" )
Expand Down Expand Up @@ -266,7 +266,7 @@ UberModule
[
( PropName "show", ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Data.Show" ) ".spago/prelude/v7.2.0/src/Data/Show.purs"
( ModuleName "Data.Show" ) ".spago/prelude/v7.2.1/src/Data/Show.purs"
[ ( Nothing, Name "showCharImpl" ) ]
)
( PropName "showCharImpl" )
Expand Down Expand Up @@ -511,7 +511,7 @@ UberModule
( App Nothing
( ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Data.Ord" ) ".spago/prelude/v7.2.0/src/Data/Ord.purs"
( ModuleName "Data.Ord" ) ".spago/prelude/v7.2.1/src/Data/Ord.purs"
[ ( Nothing, Name "ordCharImpl" ) ]
)
( PropName "ordCharImpl" )
Expand Down
4 changes: 2 additions & 2 deletions test/ps/output/Golden.CharLiterals.Test/golden.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ M.Golden_CharLiterals_Test_show = M.Data_Show_show({
show = function(n)
local code = n:byte()
if code < 0x20 or code == 0x7F then
if n == "\x07" then return "'\\a'" end
if n == "\a" then return "'\\a'" end
if n == "\b" then return "'\\b'" end
if n == "\f" then return "'\\f'" end
if n == "\n" then return "'\\n'" end
if n == "\r" then return "'\\r'" end
if n == "\t" then return "'\\t'" end
if n == "\v" then return "'\\v'" end
return "'\\" .. code:toString(10) .. "'"
return "'\\" .. tostring(code) .. "'"
end
if n == "'" or n == "\\" then return "'\\" .. n .. "'" end
return "'" .. n .. "'"
Expand Down
4 changes: 2 additions & 2 deletions test/ps/output/Golden.DerivedFunctor.Test/golden.ir
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ UberModule
( QName
{ qnameModuleName = ModuleName "Data.Semiring", qnameName = Name "foreign"
}, ForeignImport Nothing
( ModuleName "Data.Semiring" ) ".spago/prelude/v7.2.0/src/Data/Semiring.purs"
( ModuleName "Data.Semiring" ) ".spago/prelude/v7.2.1/src/Data/Semiring.purs"
[ ( Nothing, Name "intAdd" ), ( Nothing, Name "intMul" ) ]
), Standalone
( QName
Expand Down Expand Up @@ -285,7 +285,7 @@ UberModule
[
( PropName "show", ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Data.Show" ) ".spago/prelude/v7.2.0/src/Data/Show.purs"
( ModuleName "Data.Show" ) ".spago/prelude/v7.2.1/src/Data/Show.purs"
[ ( Nothing, Name "showIntImpl" ) ]
)
( PropName "showIntImpl" )
Expand Down
6 changes: 3 additions & 3 deletions test/ps/output/Golden.Fibonacci.Test/golden.ir
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ UberModule
( QName
{ qnameModuleName = ModuleName "Data.Semiring", qnameName = Name "foreign"
}, ForeignImport Nothing
( ModuleName "Data.Semiring" ) ".spago/prelude/v7.2.0/src/Data/Semiring.purs"
( ModuleName "Data.Semiring" ) ".spago/prelude/v7.2.1/src/Data/Semiring.purs"
[ ( Nothing, Name "intAdd" ), ( Nothing, Name "intMul" ) ]
), Standalone
( QName
Expand All @@ -30,7 +30,7 @@ UberModule
[
( PropName "sub", ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Data.Ring" ) ".spago/prelude/v7.2.0/src/Data/Ring.purs"
( ModuleName "Data.Ring" ) ".spago/prelude/v7.2.1/src/Data/Ring.purs"
[ ( Nothing, Name "intSub" ) ]
)
( PropName "intSub" )
Expand Down Expand Up @@ -114,7 +114,7 @@ UberModule
[
( PropName "show", ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Data.Show" ) ".spago/prelude/v7.2.0/src/Data/Show.purs"
( ModuleName "Data.Show" ) ".spago/prelude/v7.2.1/src/Data/Show.purs"
[ ( Nothing, Name "showIntImpl" ) ]
)
( PropName "showIntImpl" )
Expand Down
6 changes: 3 additions & 3 deletions test/ps/output/Golden.GenericEqTwoTypes.Test/golden.ir
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ UberModule
( QName
{ qnameModuleName = ModuleName "Data.HeytingAlgebra", qnameName = Name "foreign"
}, ForeignImport Nothing
( ModuleName "Data.HeytingAlgebra" ) ".spago/prelude/v7.2.0/src/Data/HeytingAlgebra.purs"
( ModuleName "Data.HeytingAlgebra" ) ".spago/prelude/v7.2.1/src/Data/HeytingAlgebra.purs"
[ ( Nothing, Name "boolConj" ), ( Nothing, Name "boolDisj" ), ( Nothing, Name "boolNot" ) ]
), Standalone
( QName
Expand Down Expand Up @@ -90,7 +90,7 @@ UberModule
[
( PropName "eq", ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Data.Eq" ) ".spago/prelude/v7.2.0/src/Data/Eq.purs"
( ModuleName "Data.Eq" ) ".spago/prelude/v7.2.1/src/Data/Eq.purs"
[ ( Nothing, Name "eqIntImpl" ) ]
)
( PropName "eqIntImpl" )
Expand Down Expand Up @@ -132,7 +132,7 @@ UberModule
( Nothing, Name "get", App Nothing
( ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Record.Unsafe" ) ".spago/prelude/v7.2.0/src/Record/Unsafe.purs"
( ModuleName "Record.Unsafe" ) ".spago/prelude/v7.2.1/src/Record/Unsafe.purs"
[ ( Nothing, Name "unsafeGet" ) ]
)
( PropName "unsafeGet" )
Expand Down
2 changes: 1 addition & 1 deletion test/ps/output/Golden.HelloPrelude.Test/golden.ir
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ UberModule
)
( ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Data.Unit" ) ".spago/prelude/v7.2.0/src/Data/Unit.purs"
( ModuleName "Data.Unit" ) ".spago/prelude/v7.2.1/src/Data/Unit.purs"
[ ( Just Always, Name "unit" ) ]
)
( PropName "unit" )
Expand Down
2 changes: 1 addition & 1 deletion test/ps/output/Golden.Issue37.Test/golden.ir
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ UberModule
( QName
{ qnameModuleName = ModuleName "Data.Unit", qnameName = Name "foreign"
}, ForeignImport Nothing
( ModuleName "Data.Unit" ) ".spago/prelude/v7.2.0/src/Data/Unit.purs"
( ModuleName "Data.Unit" ) ".spago/prelude/v7.2.1/src/Data/Unit.purs"
[ ( Just Always, Name "unit" ) ]
), Standalone
( QName
Expand Down
2 changes: 1 addition & 1 deletion test/ps/output/Golden.MaybeChain.Test/golden.ir
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ UberModule
[
( PropName "show", ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Data.Show" ) ".spago/prelude/v7.2.0/src/Data/Show.purs"
( ModuleName "Data.Show" ) ".spago/prelude/v7.2.1/src/Data/Show.purs"
[ ( Nothing, Name "showIntImpl" ) ]
)
( PropName "showIntImpl" )
Expand Down
6 changes: 3 additions & 3 deletions test/ps/output/Golden.ProfunctorDictLens.Test/golden.ir
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ UberModule
( QName
{ qnameModuleName = ModuleName "Data.Semiring", qnameName = Name "foreign"
}, ForeignImport Nothing
( ModuleName "Data.Semiring" ) ".spago/prelude/v7.2.0/src/Data/Semiring.purs"
( ModuleName "Data.Semiring" ) ".spago/prelude/v7.2.1/src/Data/Semiring.purs"
[ ( Nothing, Name "intAdd" ), ( Nothing, Name "intMul" ) ]
), Standalone
( QName
Expand Down Expand Up @@ -368,7 +368,7 @@ UberModule
[
( PropName "show", ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Data.Show" ) ".spago/prelude/v7.2.0/src/Data/Show.purs"
( ModuleName "Data.Show" ) ".spago/prelude/v7.2.1/src/Data/Show.purs"
[ ( Nothing, Name "showIntImpl" ) ]
)
( PropName "showIntImpl" )
Expand Down Expand Up @@ -556,7 +556,7 @@ UberModule
[
( PropName "sub", ObjectProp ( Just Always )
( ForeignImport Nothing
( ModuleName "Data.Ring" ) ".spago/prelude/v7.2.0/src/Data/Ring.purs"
( ModuleName "Data.Ring" ) ".spago/prelude/v7.2.1/src/Data/Ring.purs"
[ ( Nothing, Name "intSub" ) ]
)
( PropName "intSub" )
Expand Down
1 change: 1 addition & 0 deletions test/ps/output/Golden.StringCodePoints.Test/corefn.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
actual.txt
12 changes: 12 additions & 0 deletions test/ps/output/Golden.StringCodePoints.Test/eval/golden.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[97,233,1071,119808,122]
5
10
[97,233]
[1071,119808,122]
(Just 97)
(Just 119808)
Nothing
(Just 97)
(Just [233,1071,119808,122])
true
[119808]
Loading
Loading