-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add miraculix testing library #1
Conversation
Wow, this is really nice! This isn't just a nice PureNix library, this would just be a convenient library in general for Nix. I almost feel like you should wrap this up in a thin Nix API and release it as a normal Nix library. For instance, here's the {
tests =
module."Test.Miraculix.TestTree".testGroup
"Lib functions"
[ ( module."Test.Miraculix.TestTree".testGroup
"Math"
[ ( module."Data.Function".apply
( module."Test.Miraculix.TestTree".testCase "addition" )
( module."Test.Miraculix.Assertion".assertEq module."Data.Show".showInt module."Data.Eq".eqInt (module."Data.Semiring".add module."Data.Semiring".semiringInt 1 1) 2 )
)
( module."Data.Function".apply
( module."Test.Miraculix.TestTree".testCase "muliplication")
( module."Test.Miraculix.Assertion".assertEq module."Data.Show".showInt module."Data.Eq".eqInt (module."Data.Semiring".mul module."Data.Semiring".semiringInt 3 4) 11 )
)
]
)
( module."Test.Miraculix.TestTree".testGroup "Strings"
[ ( module."Data.Function".apply
( module."Test.Miraculix.TestTree".testCase "sorts a list of numbers" )
( module."Test.Miraculix.Assertion".assertEq
( module."Data.Show".showArray module."Data.Show".showInt )
( module."Data.Eq".eqArray module."Data.Eq".eqInt )
( module."Data.Array".sort module."Data.Ord".ordInt [2 3 1] )
[1 2 3]
)
)
( module."Data.Function".apply
( module."Test.Miraculix.TestTree".testCase "sorts a list of characters" )
( module."Test.Miraculix.Assertion".assertEq
( module."Data.Show".showArray module."Data.Show".showChar )
( module."Data.Eq".eqArray module."Data.Eq".eqChar )
( module."Data.Array".sort module."Data.Ord".ordChar ["c" "b" "a"] )
["a" "b"]
)
)
]
)
];
} This is both easy to read and write. But if you clean up some of the unnecessary PureNix stuff, it looks even better: {
tests =
testGroup
"Lib functions"
[ (testGroup
"Math"
[ (testCase "addition" (assertEq showInt eqInt (add semiringInt 1 1) 2))
(testCase "muliplication" (assertEq showInt eqInt (mul semiringInt 3 4) 11))
]
)
(testGroup
"Strings"
[ (testCase
"sorts a list of numbers"
(assertEq (showArray showInt) (eqArray eqInt) (sort ordInt [2 3 1]) [1 2 3])
)
(testCase
"sorts a list of characters"
(assertEq (showArray showChar) (eqArray eqChar) (sort ordChar ["c" "b" "a"]) ["a" "b"])
)
]
)
];
} Aside from the typeclass instances (like |
Also, I see in the most recent version of I wrote a little about It looks like you're using The two concerns I would have about this are:
So yeah, after thinking this through, it seems like I may just have been wrong here and If you want to move forward with |
This is just another thought I had (but I don't think you should necessarily let it determine the direction you take I'd like to get support in PureNix for handling The problem is that the more dependencies the testing framework has, the fewer packages in the standard library that could use the testing framework. For instance, if the testing framework doesn't have any dependencies, it could be used to test every package in the standard library. Oppositely, if the testing framework has a dependency on a package like Moving forward, it might be ideal to have two separate testing frameworks. One like |
I agree, it's quite debatable if an Effect type does make any sense in a purenix context. When I first started to think about this I was almost sure that having Effect would not be necessary because of Nix's already pure nature. As you have seen, miraculix At the moment I can only say that this works out. But I'm not sure if this implementation may have other unwanted implications. So from a practical point of view I'd say I already gained from using Regarding the And as you say, unfortunately there's no way to catch the thrown value. But with those limitations in mind, a If higher level libraries make sure that normal functions don't However, I don't think that Nix functions like But there are also functions like At the moment I think: If those functions would be typed as e.g. I had the idea of having a standard library for purenix. It could provide a set of well typed bindings to the most important builtin functions. Especially the very Regarding the idea of having an additional dependency free testing framework: I think this could really make sense. In the end it would mean that some portions of basic libraries would have to be copy/pasted into the test framework. But this would bring in a clean dependency graph. I can very well imagine implementing this in the future. And yes, maybe I'll consider publishing the lib as a Thanks a lot for the suggestions! I'm excited to see where the discussion about the |
Hi, first of all thanks for writing purenix! I think this is a really useful and promising approach to write typed nix!
It inspired me to write this small testing library which is inspired by
tasty
. With this PR I'd like to ask if it could be listed in the package set.Working with the current purenix version was really smooth.
The only issue I encountered was the quoting thing already mentioned in here.