<commit_before>{-# LANGUAGE OverloadedStrings #-}
import Test.HUnit
import ProjectM36.Base
import ProjectM36.Atom
import qualified ProjectM36.Attribute as A
import TutorialD.Interpreter.Import.TutorialD
import System.Exit
import System.IO.Temp
import qualified ProjectM36.DatabaseContext as DC
import qualified Data.Vector as V
import System.IO


main :: IO ()
main = do 
  tcounts <- runTestTT $ TestList [testTutdImport]
  if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess

testTutdImport :: Test
testTutdImport = TestCase $ do
  withSystemTempFile "m.tutd" $ \tempPath handle -> do
    hPutStrLn handle "x:=relation{tuple{a 5,b \"spam\"}}"
    hClose handle
    let expectedExpr = MultipleExpr [Assign "x" (ExistingRelation (Relation expectedAttrs $ RelationTupleSet [RelationTuple expectedAttrs $ V.fromList [intAtom 5, stringAtom "spam"]]))]
        expectedAttrs = A.attributesFromList [Attribute "a" intAtomType, Attribute "b" stringAtomType]
    imported <- importTutorialD tempPath DC.empty  
    assertEqual "import tutd" (Right expectedExpr) imported<commit_msg>WIP: fix changed parseTutorialD signature<commit_after>{-# LANGUAGE OverloadedStrings #-}
import Test.HUnit
import ProjectM36.Base
import ProjectM36.Atom
import qualified ProjectM36.Attribute as A
import TutorialD.Interpreter.Import.TutorialD
import System.Exit
import System.IO.Temp
import qualified Data.Vector as V
import System.IO

main :: IO ()
main = do 
  tcounts <- runTestTT $ TestList [testTutdImport]
  if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess

testTutdImport :: Test
testTutdImport = TestCase $ do
  withSystemTempFile "m.tutd" $ \tempPath handle -> do
    hPutStrLn handle "x:=relation{tuple{a 5,b \"spam\"}}"
    hClose handle
    let expectedExpr = MultipleExpr [Assign "x" (ExistingRelation (Relation expectedAttrs $ RelationTupleSet [RelationTuple expectedAttrs $ V.fromList [intAtom 5, stringAtom "spam"]]))]
        expectedAttrs = A.attributesFromList [Attribute "a" intAtomType, Attribute "b" stringAtomType]
    imported <- importTutorialD tempPath
    assertEqual "import tutd" (Right expectedExpr) imported
{'fraction_non_alphanumeric': 0.08556891766882516, 'fraction_numerical': 0.009250693802035153, 'mean_word_length': 5.008333333333334, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3098981', 'n_tokens_mistral': 694, 'n_tokens_neox': 668, 'n_words': 199}