diff options
| author | Arnaud Bailly <arnaud@pankzsoft.com> | 2026-03-22 16:05:42 +0100 |
|---|---|---|
| committer | Arnaud Bailly <arnaud@pankzsoft.com> | 2026-03-22 16:05:42 +0100 |
| commit | a1e0b0e5071f851c865ae567de7a28014a1eafc4 (patch) | |
| tree | 93caa8cb5803566b1fa5792ac230b5a1974db7e0 /lambda-calcul/haskell/test/Minilang/Lambda/DeBruijnSpec.hs | |
| parent | 4fed459d89b6b3abcce8028b19af806b48a38bd7 (diff) | |
| download | lambda-nantes-a1e0b0e5071f851c865ae567de7a28014a1eafc4.tar.gz | |
Add strings handling
Diffstat (limited to 'lambda-calcul/haskell/test/Minilang/Lambda/DeBruijnSpec.hs')
| -rw-r--r-- | lambda-calcul/haskell/test/Minilang/Lambda/DeBruijnSpec.hs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lambda-calcul/haskell/test/Minilang/Lambda/DeBruijnSpec.hs b/lambda-calcul/haskell/test/Minilang/Lambda/DeBruijnSpec.hs index eaff77c..f1802da 100644 --- a/lambda-calcul/haskell/test/Minilang/Lambda/DeBruijnSpec.hs +++ b/lambda-calcul/haskell/test/Minilang/Lambda/DeBruijnSpec.hs @@ -81,3 +81,37 @@ spec = do it "lookup of '+' in builtin env yields FBuiltin" $ eval' benv (FV "+") `shouldBe` FBuiltin "+" + + describe "string literals and builtins" $ do + let benv = builtinDeBruijnEnv :: Env Text + + it "FStr self-evaluates" $ + eval' benv (FStr "hello") `shouldBe` FStr "hello" + + it "(str-concat \"foo\" \"bar\") reduces to FStr \"foobar\"" $ + eval' benv (App (App (FBuiltin "str-concat") (FStr "foo")) (FStr "bar")) + `shouldBe` FStr "foobar" + + it "(str-length \"hello\") reduces to FNum 5" $ + eval' benv (App (FBuiltin "str-length") (FStr "hello")) + `shouldBe` FNum 5 + + it "(str-slice 1 3 \"abcde\") reduces to FStr \"bc\"" $ + eval' benv (App (App (App (FBuiltin "str-slice") (FNum 1)) (FNum 3)) (FStr "abcde")) + `shouldBe` FStr "bc" + + it "(str= \"abc\" \"abc\") reduces to Church True" $ + eval' benv (App (App (FBuiltin "str=") (FStr "abc")) (FStr "abc")) + `shouldBe` Lam "f" (Lam "t" (Var "t" 0)) + + it "(str= \"abc\" \"xyz\") reduces to Church False" $ + eval' benv (App (App (FBuiltin "str=") (FStr "abc")) (FStr "xyz")) + `shouldBe` Lam "f" (Lam "t" (Var "f" 1)) + + it "(str< \"a\" \"b\") reduces to Church True" $ + eval' benv (App (App (FBuiltin "str<") (FStr "a")) (FStr "b")) + `shouldBe` Lam "f" (Lam "t" (Var "t" 0)) + + it "(str-concat \"hello\") is partial: stays as App spine" $ + eval' benv (App (FBuiltin "str-concat") (FStr "hello")) + `shouldBe` App (FBuiltin "str-concat") (FStr "hello") |
