erlang

More human-friendly tests messages with Erlang EUnit?

拟墨画扇 提交于 2019-12-11 06:59:35
问题 I am used to JavaScript testing, especially its BDD frameworks and libraries like Chai where I can describe tests in a human-friendly manner and name tests with strings, e.g. "UserProfile -> Update First Name", then see these message as the output when running tests. Is it possible to write Erlang tests in a more natural way, or at least, integrate descriptions in to tests run process, not just have them as comments, but see the name of a test which failed? 回答1: Yes. To add descriptions to

IPython Language Kernel Implementation in Erlang

孤者浪人 提交于 2019-12-11 06:55:48
问题 I'm currently building an Erlang language kernel backend for IPython, and I'm testing it out in the console. What I have working: Start ipython console and the erlang kernel Erlang kernel reads contents of kernel.json file which contains all the port numbers for zmq Create zmq bindings for the shell , heartbeat , control , iopub sockets using the erlzmq2 library. Created functions to parse messages from IPython Create a process for the heartbeat server to run on and return messages to IPython

Why Can't I Delete Files With A Tilde?

帅比萌擦擦* 提交于 2019-12-11 06:44:37
问题 Elixir 1.3.2 Erlang/OTP 19 Windows 7 (Standard User and Administrator) I'm trying to hack together a small Elixir script to wrap around commiting files to git. The first thing I do, in order to insure I don't accidentally stage temporary files created by emacs is File.rm("*~"). However, this is what I get: iex(2)> File.rm("*~") {:error, :eio} So I tried File.rm("*.*~") . Same result. I get the same behavior when I run as either a Standard User (which is how I normally work on Windows) or as

How to play an AIFF sound file using Erlang?

╄→尐↘猪︶ㄣ 提交于 2019-12-11 06:34:05
问题 I am trying to look for a way to play an AIFF file using Erlang. I have found this tutorial, but it seems to be only about reading the content of the file and not actually playing it. 回答1: I suggest using the linux command "play" with "os:cmd" or "ports". It is quite ad-hoc but it is not a very uncommon command and it may do the trick. 来源: https://stackoverflow.com/questions/15199075/how-to-play-an-aiff-sound-file-using-erlang

Can I handle any received message in gen_fsm state callbacks?

我只是一个虾纸丫 提交于 2019-12-11 06:16:52
问题 I noticed that messages sent to the pid of a gen_fsm process are matched in the state callbacks as events. Is this just accidental or can I rely on this feature? Normally I would expect general messages sent to a gen_fsm to show up in the handle_info/3 callback and thought I would have to re-send it using gen_fsm:send_event. Does gen_fsm try to match the message first to the state callback and then allways with the handle_info/3 callback? Or only if it doesn't match a state callback clause?

Erlang conversion for one format to another format

↘锁芯ラ 提交于 2019-12-11 06:13:17
问题 How to convert this string format "{hari, localost}" into this: {"hari", "localost"} , in Erlang? I tried to convert this format with lot of trial and error method, but I can't get the solution. 回答1: I guess you need to convert from string, so you can use the modules erl_scan and erl_parse: 1> erl_scan:string("{hari, localost}"++"."). {ok,[{'{',1}, {atom,1,hari}, {',',1}, {atom,1,localost}, {'}',1}, {dot,1}], 1} 2> {ok,Term} = erl_parse:parse_term(Tokens). {ok,{hari,localost}} 3>Conv = fun({X

Variable is unbound when used to pattern match as a key in a map

試著忘記壹切 提交于 2019-12-11 06:03:22
问题 I want to pattern match a map on a key when the second argument is a map with name 's value being the same as the key in the first argument's map. Instead I get this: 8> c(room). room.erl:23: variable 'PlayerName' is unbound error status({_Players, _Tables, ChallengerName}, #{name := ChallengerName}) -> #{status => challenging}; status({#{PlayerName := PlayerStatus}, _, _}, #{name := PlayerName}) -> PlayerStatus; status(_, _) -> #{status => null}. Oddly, the first function declaration works

Try catch around list_to_integer doesn't catch error

喜夏-厌秋 提交于 2019-12-11 05:18:50
问题 1> foo:inter(). ** exception error: bad argument in function foo:inter/0 (foo.erl, line 7) -module(foo). -compile(export_all). inter() -> A = <<"5a">>, B = binary_to_list(A), try list_to_integer(B) of Result -> Result catch _ -> {error, bad_integer} end. I expected to get {error, bad_integer}. 回答1: There are 3 types of exceptions in Erlang: error , exit and throw . catch clauses are of the format Type:Pattern . When a Type is not specified, like in your code, only throw exceptions are caught

Elixir io_lib call to erlang

拥有回忆 提交于 2019-12-11 05:05:15
问题 io_lib:fread("~d/~d/~d", "2013/03/03"). Above code works in erlang so ideally in elixir below code should work :io_lib.fread("~d/~d/~d", "2013/03/03") but it generates error " no function clause matching " After inspecting found that elixir makes call to module like :io_lib_fread.fread("~d/~d/~d", "2013/03/03", 0, []) 回答1: A double quote in erlang "char list" translates to single quotes in Elixir 'char list' . 来源: https://stackoverflow.com/questions/18756293/elixir-io-lib-call-to-erlang

erlang is no longer supported by Red Hat Enterprise Linux?

情到浓时终转凉″ 提交于 2019-12-11 04:36:07
问题 I'm trying installing Erlang on my REHL7.2, but unfortunately I failed. I tried two approaches First I tried downloading a RPM package from official site of erlang (in fact the rpm package is for CentOS, but there's no RPM package for RHEL anyway), but error: Failed dependencies: libwx_baseu-2.8.so.0()(64bit) is needed by esl-erlang-19.0-1.x86_64 libwx_baseu-2.8.so.0(WXU_2.8)(64bit) is needed by esl-erlang-19.0-1.x86_64 Then I tried $ wget http://packages.erlang-solutions.com/erlang-solutions