clojure

How do I unit test clojure.core.async go macros?

a 夏天 提交于 2021-02-06 15:24:30
问题 I'm trying to write unit tests when using core.async go macros. Writing the test naively, as follows, appears that the code inside the go blocks doesn't get executed. (ns app.core-test (:require [clojure.test :refer :all] [clojure.core.async :as async])) (deftest test1 [] (let [chan (async/chan)] (async/go (is (= (async/<! chan) "Hello"))) (async/go (async/>! chan "Hello")))) I've managed to get the following working, but it's extremely hacky. (deftest test1 [] (let [result (async/chan) chan

Clojure merge multiple map into a single map

孤街醉人 提交于 2021-02-06 15:23:16
问题 I have the following list of maps ({"child.search" {:roles #{"ROLE_ADM_UNSUBSCRIBE_SUBSCRIPTION" "ROLE_ADM_SEARCH_SUBSCRIPTION" "ROLE_ADM_VIEW_SUBSCRIPTION"}}, "child.cc.search" {:roles #{"ROLE_ADM_CC_SEARCH_SUBSCRIPTION" "ROLE_ADM_CC_VIEW_SUBSCRIPTION"}}} {"child.abusereport" {:roles #{"ROLE_ADM_ABUSE_RPT"}}, "child.manualfiltering" {:roles #{"ROLE_ADM_MANUAL_FILTERING_RPT"}}} {"child.assigned.advertisement" {:roles #{"ROLE_ADM_CREATE_ADVERTISING"}}, "child.manage.advertisement" {:roles #{

Clojure merge multiple map into a single map

我是研究僧i 提交于 2021-02-06 15:21:13
问题 I have the following list of maps ({"child.search" {:roles #{"ROLE_ADM_UNSUBSCRIBE_SUBSCRIPTION" "ROLE_ADM_SEARCH_SUBSCRIPTION" "ROLE_ADM_VIEW_SUBSCRIPTION"}}, "child.cc.search" {:roles #{"ROLE_ADM_CC_SEARCH_SUBSCRIPTION" "ROLE_ADM_CC_VIEW_SUBSCRIPTION"}}} {"child.abusereport" {:roles #{"ROLE_ADM_ABUSE_RPT"}}, "child.manualfiltering" {:roles #{"ROLE_ADM_MANUAL_FILTERING_RPT"}}} {"child.assigned.advertisement" {:roles #{"ROLE_ADM_CREATE_ADVERTISING"}}, "child.manage.advertisement" {:roles #{

How do I unit test clojure.core.async go macros?

点点圈 提交于 2021-02-06 15:20:49
问题 I'm trying to write unit tests when using core.async go macros. Writing the test naively, as follows, appears that the code inside the go blocks doesn't get executed. (ns app.core-test (:require [clojure.test :refer :all] [clojure.core.async :as async])) (deftest test1 [] (let [chan (async/chan)] (async/go (is (= (async/<! chan) "Hello"))) (async/go (async/>! chan "Hello")))) I've managed to get the following working, but it's extremely hacky. (deftest test1 [] (let [result (async/chan) chan

Using React Native MapView in ClojureScript Reagent

只谈情不闲聊 提交于 2021-02-06 13:53:43
问题 I am trying to use MapView from https://github.com/airbnb/react-native-maps using Reagent. It works fine but how could I get local state for MapView when onRegionChange event is fired? Trying to use current/component but it is always nil . (def Expo (js/require "expo")) (def map-view (r/adapt-react-class (.-MapView Expo))) (defn my-map [] (r/create-class {:component-did-mount (fn [this] (println "component mount ")) :reagent-render (fn [] (let [this (r/current-component)] [map-view {:style {

Using React Native MapView in ClojureScript Reagent

*爱你&永不变心* 提交于 2021-02-06 13:50:55
问题 I am trying to use MapView from https://github.com/airbnb/react-native-maps using Reagent. It works fine but how could I get local state for MapView when onRegionChange event is fired? Trying to use current/component but it is always nil . (def Expo (js/require "expo")) (def map-view (r/adapt-react-class (.-MapView Expo))) (defn my-map [] (r/create-class {:component-did-mount (fn [this] (println "component mount ")) :reagent-render (fn [] (let [this (r/current-component)] [map-view {:style {

Using React Native MapView in ClojureScript Reagent

有些话、适合烂在心里 提交于 2021-02-06 13:50:50
问题 I am trying to use MapView from https://github.com/airbnb/react-native-maps using Reagent. It works fine but how could I get local state for MapView when onRegionChange event is fired? Trying to use current/component but it is always nil . (def Expo (js/require "expo")) (def map-view (r/adapt-react-class (.-MapView Expo))) (defn my-map [] (r/create-class {:component-did-mount (fn [this] (println "component mount ")) :reagent-render (fn [] (let [this (r/current-component)] [map-view {:style {

Obfuscating clojure uberjars with ProGuard

二次信任 提交于 2021-02-05 18:53:28
问题 I was wondering if anybody has any experience with obfuscating their leiningen compiled uberjars with proguard. I've tried my best to look for a solution on Google but couldn't really find an answer. I'm wondering if this is at all possible. I've been trying to obfuscate a default lein project. Here's the core.clj file: (ns proguard.core (:gen-class)) (defn -main "I don't do a whole lot." [& args] (println "Hello, World!")) the project file: (defproject proguard "0.1.0-SNAPSHOT" :description

Can anyone explain me about the sh in clojure in order to execute the system command?

筅森魡賤 提交于 2021-02-05 12:24:55
问题 I'm using Mac OS. I want to execute a system command using (use '[clojure.java.shell :only [sh]]) , like in How to execute system commands?. I have read https://clojuredocs.org/clojure.java.shell/sh but wasn't able to understand things like how many parameters can be passed in one syntax, etc. In windows I have tried (sh "cmd" "/C" "dir") and it was working but in Mac OS, how do I execute the above syntax? Moreover I want to pass more parameters than just dir . For example, I want to execute

Generating a symbol from a string and applying it as a function

。_饼干妹妹 提交于 2021-02-05 10:11:59
问题 I'm just learning clojure, and I'm hitting a wall. I'm trying to read an arithmetic expression as an infix string and process it in Clojure. e.g. "1 + 2" -> (+ 1 2) I read in the "+" and turn it into a symbol like this: (def plus (symbol "clojure.core" "+")) Which appears to work properly, but when I call it, I don't get what I'm expecting: user=> plus + user=> (plus 1 1) 1 user=> (plus 1 2) 2 user=> (plus 1 2 3) ArityException Wrong number of args (3) passed to: Symbol clojure.lang.AFn