This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-07
Channels
- # beginners (19)
- # cider (20)
- # cljs-dev (2)
- # cljsjs (2)
- # clojure (61)
- # clojure-spec (13)
- # clojure-uk (12)
- # clojurescript (12)
- # core-typed (1)
- # cursive (16)
- # data-science (30)
- # datomic (37)
- # fulcro (8)
- # hoplon (7)
- # jobs-discuss (1)
- # onyx (21)
- # planck (18)
- # protorepl (1)
- # re-frame (2)
- # reagent (1)
- # shadow-cljs (6)
- # tools-deps (4)
can you sketch it out a bit? i bet there's a good clean solution without redefs and dynamic vars
What I need for some of my tests is created through something that I'm also testing in the same test namespace
But if I just def this in my tests, so the tests that needs thing just use it from def. It means if (make-thing) doesn't work, the def could fail
that sounds like break them into two tests. test creating the thing. and then test handling of the thing with a well-formed test version of the thing
that way you can test the latter half with the bad conditions that can arise as well
But the order matters then. Like, I can't create the thing until I've run the test for it.
and it has to be that thing that is created? you can't mock one or have generated input to the second test?
I mean, I'm definitly being a bit pedantic. Because the edge case is that (make-thing) throws an exception, and then I'm not sure what happens to the test when running if a def in a test namespace throws
one option I've used is a function that calls is, and calling that function inside a test
this works because deftest/is interaction is via dynamic scope
I assumed it breaks the tests from running. So by first testing that make-thing works, I'm hoping instead of say, the tests not running at all because it threw an exception in the def, instead I see tests failing for make-thing that show me directly where the error is
Anyways, dynamic vars were not that ugly to put in. But I feel its too bad deftest can't take args. Would be nice just for say running a bunch of tests over a huge list of inputs or something.
wat?
(reduce + 0 [1 2 3 nil])
=> java.lang.NullPointerException
(reduce (fnil + 0) 0 [1 2 3 nil])
=> java.lang.NullPointerException
([a b] (f (if (nil? a) x a) b))
should be the branch here. a
is 6 so you get a and the b
without changing it
(fnil + 0 0)
also hi, we are coworkers
i always forget about the other arities of fnil. despite having just looked at the source lol
hi, quick q, i have a lein project with a main entry point; Is there anyway to not run -main
when just doing a lein repl
? I don't like having to constantly change my project.clj
just to get to my repl.
Hey @joefromct, see here: https://github.com/technomancy/leiningen/blob/stable/sample.project.clj#L362-L364 -- there's a nested keyword option you can set in your project.clj: :repl-options
> :init-ns
. You set it to the namespace that you want to load for REPL sessions.
@joefromct I use a special user
namespace that is specifically for my REPL sessions. It imports other libraries and defines functions that I use often in the REPL. I got the idea from here: http://www.luminusweb.net/docs#creating_a_new_application (The Luminus project template is focused on web apps, but it might still be helpful for you)
I have a clojure nrepl server running on an ubutnu server , but I cannot remotly connect via nrepl. Probably the port is blocked. Is there a way I can use my ssh connection to connect via ssh?
@mx2000 you’re possibly looking for ssh port forwarding https://www.ssh.com/ssh/tunneling/example
@mx2000 the connection is from the local host only intentionally since a repl is a huge security hole
but yes, the right thing to do is port forward