dataframe-0.3.4.1: tests/Functions.hs
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
module Functions where
import DataFrame.Functions (
col,
sanitize,
)
import DataFrame.Synthesis (generatePrograms)
import Test.HUnit
-- Test cases for the sanitize function
sanitizeIdentifiers :: Test
sanitizeIdentifiers =
TestList
[ TestCase $
assertEqual
"Reserved word 'Data' should become '_data_'"
"_data_"
(sanitize "Data")
, TestCase $
assertEqual
"Spaces should become underscores"
"my_data"
(sanitize "My Data")
, TestCase $
assertEqual
"Punctuation and parentheses should be handled"
"distance_km_h"
(sanitize "Distance (km/h)")
, TestCase $
assertEqual
"Leading digit should be wrapped"
"_0_age_"
(sanitize "0 Age")
, TestCase $
assertEqual
"Valid camelCase should be unchanged"
"camelCaseStr"
(sanitize "camelCaseStr")
, TestCase $
assertEqual
"Valid camelCase with invalid characters mixed in"
"camelcase_str"
(sanitize "camelCase$Str")
, TestCase $
assertEqual
"Valid snake_case should remain unchanged"
"snake_case_str"
(sanitize "snake_case_str")
, TestCase $
assertEqual
"Leading digit with snake_case should be wrapped"
"_12_snake_case_"
(sanitize "12_snake_case")
, TestCase $
assertEqual
"All symbols should become underscores"
"_____"
(sanitize "***")
]
generateProgramsCalledWithNoExistingPrograms :: Test
generateProgramsCalledWithNoExistingPrograms =
TestCase
( assertEqual
"generatePrograms called with no existing programs"
[col @Double "x"]
(generatePrograms True [] [col "x"] [] [])
)
tests :: [Test]
tests =
[ TestLabel "sanitizeIdentifiers" sanitizeIdentifiers
, TestLabel
"generateProgramsCalledWithNoExistingPrograms"
generateProgramsCalledWithNoExistingPrograms
]