{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE OverloadedRecordDot #-} {-# HLINT ignore "Use const" #-} {-# HLINT ignore "Unused LANGUAGE pragma" #-} {-# HLINT ignore "Avoid lambda" #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE NoFieldSelectors #-} {-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} {-# LANGUAGE TypeApplications #-} module Test.Datalog.NaiveDatabaseSpec where import Test.Hspec import Datalog.NaiveDatabase import qualified Datalog.NaiveDatabase as NaiveDatabase -- checkParse :: String -> Expr -> Expectation -- checkParse text expectedExpr = -- parse parseExpr "" text `shouldBe` Right expectedExpr -- checkEval :: String -> Int -> Expectation -- checkEval text expectedVal = -- fmap eval (parse parseExpr "" text) `shouldBe` Right expectedVal -- getConfig :: IO Config -- getConfig = do -- env <- lookupEnv "APP_ENV" -- let fallbackHosts = -- [ "localhost:8080" -- , "127.0.0.1:9000" -- , "backup.example.com" -- ] -- pure Config -- { port = 3000 -- , hosts = fromMaybe fallbackHosts env -- , logLevel = Info -- } spec :: Spec spec = do describe "dummy test" $ do it "..." $ do 1 `shouldBe` (1 :: Int) it "can accept facts and do basic queries" $ do -- let fallbackHosts = -- [ "localhost:8080" -- , "127.0.0.1:9000" -- , "backup.example.com" -- ] -- let names = -- [ "Alice" -- , "Bob" -- , "Charlie" -- , "Daphne" -- , "Eve" -- ] -- let twig = -- [ "xx" -- , "yy " ] -- let pig = -- [ "parent(\"alice\", \"bob\")." -- , "parent(\"bob\", \"carol\")." -- ] let db = NaiveDatabase.withFacts [ "parent(\"alice\", \"bob\")." , "parent(\"bob\", \"carol\")." ] query db"?- parent(alice,X)." `shouldBe` "#NYI" -- ideally, 'bob'