mirror of
https://github.com/gren-lang/compiler.git
synced 2024-09-11 08:45:42 +03:00
Setup test suite for encoding VLQs
This commit is contained in:
parent
f6853ededa
commit
56dc275d6f
7
compiler/src/Generate/VLQ.hs
Normal file
7
compiler/src/Generate/VLQ.hs
Normal file
@ -0,0 +1,7 @@
|
||||
module Generate.VLQ
|
||||
( encode
|
||||
) where
|
||||
|
||||
encode :: Int -> String
|
||||
encode _num =
|
||||
""
|
@ -153,6 +153,7 @@ Common gren-common
|
||||
Generate.JavaScript.Name
|
||||
Generate.Mode
|
||||
Generate.SourceMap
|
||||
Generate.VLQ
|
||||
Nitpick.Debug
|
||||
Nitpick.PatternMatches
|
||||
Optimize.Case
|
||||
@ -255,6 +256,7 @@ Test-Suite gren-tests
|
||||
Helpers.Parse
|
||||
|
||||
-- tests
|
||||
Generate.VLQSpec
|
||||
Integration.FormatSpec
|
||||
Parse.AliasSpec
|
||||
Parse.RecordUpdateSpec
|
||||
|
19
tests/Generate/VLQSpec.hs
Normal file
19
tests/Generate/VLQSpec.hs
Normal file
@ -0,0 +1,19 @@
|
||||
module Generate.VLQSpec (spec) where
|
||||
|
||||
import Generate.VLQ (encode)
|
||||
import Test.Hspec (Spec, describe, it, shouldBe)
|
||||
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
describe "VLQ tests" $ do
|
||||
it "Encodes from Int to String" $ do
|
||||
encode 0 `shouldBe` "A"
|
||||
encode 1 `shouldBe` "C"
|
||||
encode (-1) `shouldBe` "D"
|
||||
encode 3 `shouldBe` "G"
|
||||
encode 123 `shouldBe` "2H"
|
||||
encode 123456789 `shouldBe` "qxmvrH"
|
||||
-- limits:
|
||||
encode (-2147483648) `shouldBe` "B"
|
||||
encode 2147483647 `shouldBe` "+/////D"
|
Loading…
Reference in New Issue
Block a user