on master help sign in
fix fromGregorian Day constructor
commit660df0bd846d46eefde3193e1b0d886bb836e8de authorAgentM <agentm@themactionfaction.com> dateThu 24 May 2018, 20:01 (8 years ago) parent0a73890
2 files changed+6−3
src/lib/ProjectM36/DataTypes/Day.hs+2−2 test/TutorialD/Interpreter.hs+4−1
src/lib/ProjectM36/DataTypes/Day.hs+2−2
@@ -7,8 +7,8 @@ import Data.Time.Calendar
77dayAtomFunctions :: AtomFunctions
88dayAtomFunctions = HS.fromList [
99 AtomFunction { atomFuncName = "fromGregorian",
10− atomFuncType = [IntAtomType, IntAtomType, IntAtomType, DayAtomType],
11− atomFuncBody = compiledAtomFunctionBody $ \(IntAtom year:IntAtom month:IntAtom day:_) -> pure $ DayAtom (fromGregorian (fromIntegral year) (fromIntegral month) (fromIntegral day))
10+ atomFuncType = [IntegerAtomType, IntegerAtomType, IntegerAtomType, DayAtomType],
11+ atomFuncBody = compiledAtomFunctionBody $ \(IntegerAtom year:IntegerAtom month:IntegerAtom day:_) -> pure $ DayAtom (fromGregorian (fromIntegral year) (fromIntegral month) (fromIntegral day))
1212 },
1313 AtomFunction { atomFuncName = "dayEarlierThan",
1414 atomFuncType = [DayAtomType, DayAtomType, BoolAtomType],
test/TutorialD/Interpreter.hs+4−1
@@ -29,6 +29,7 @@ import Data.Text hiding (map)
2929import qualified Data.Text as T
3030import Data.Time.Clock.POSIX hiding (getCurrentTime)
3131import Data.Time.Clock (getCurrentTime)
32+import Data.Time.Calendar (fromGregorian)
3233
3334main :: IO ()
3435main = do
@@ -157,7 +158,9 @@ main = do
157158 ("x:=relation{tuple{a Left 3}}", Left (TypeConstructorTypeVarsMismatch (S.fromList ["a","b"]) (S.fromList ["a"]))), -- Left 3, alone is not enough information to imply the type
158159 ("x:=relation{a Either Integer Text}{tuple{a Left 3}}", mkRelationFromList simpleEitherIntTextAttributes [[ConstructedAtom "Left" (eitherAtomType IntegerAtomType TextAtomType) [IntegerAtom 3]]]),
159160 --test datetime constructor
160− ("x:=relation{tuple{a dateTimeFromEpochSeconds(1495199790)}}", mkRelationFromList (A.attributesFromList [Attribute "a" DateTimeAtomType]) [[DateTimeAtom (posixSecondsToUTCTime(realToFrac (1495199790 :: Int)))]])
161+ ("x:=relation{tuple{a dateTimeFromEpochSeconds(1495199790)}}", mkRelationFromList (A.attributesFromList [Attribute "a" DateTimeAtomType]) [[DateTimeAtom (posixSecondsToUTCTime(realToFrac (1495199790 :: Int)))]]),
162+ --test Day constructor
163+ ("x:=relation{tuple{a fromGregorian(2017,05,30)}}", mkRelationFromList (A.attributesFromList [Attribute "a" DayAtomType]) [[DayAtom (fromGregorian 2017 05 30)]])
161164 ]
162165
163166assertTutdEqual :: DatabaseContext -> Either RelationalError Relation -> Text -> Assertion