Skip to content

Instantly share code, notes, and snippets.

@zkessin
zkessin / fixtures.erl
Created August 24, 2012 20:43
test with fixtures
do_something_with_fixtures_test_() ->
{
setup,
fun setup/0,
fun cleanup/1,
?_test(
begin
?assertEqual(1, 2)
end)}.
@zkessin
zkessin / square.erl
Created August 24, 2012 20:45
square.erl
-module(square).
-export([square/1]).
square(X) ->
X * X.
@zkessin
zkessin / square_test.erl
Created August 24, 2012 20:45
square_test.erl
-module(square_test).
-include_lib("eunit/include/eunit.hrl").
square_0_test() ->
?assertEqual(0, square:square(0)).
square_1_test() ->
?assertEqual(1, square:square(1)).
square_2_test() ->
@zkessin
zkessin / tests.erl
Created August 24, 2012 20:45
Eunit Basic Test
-module(tests).
-export([run/0]).
run() ->
io:format("Running Tests"),
eunit:test("ebin/"),
init:stop().
@zkessin
zkessin / Makefile.txt
Created August 24, 2012 20:48
Erlang Makefile
test: all
erl -run tests run
@zkessin
zkessin / cover.erl
Created August 24, 2012 20:49
Erlang Code Coverage
-module(cover).
-export([ cover/0]).
cover()->
io:format("~n********************************************************************************~n"),
io:format("Running Tests~n~n"),
cover:start(),
_R = cover:compile_beam_directory("ebin/"),
@zkessin
zkessin / gist:3635710
Created September 5, 2012 12:09
run-phantomjs
(defun run-phantomjs ()
(message "Phantom JS: %s"
(shell-command-to-string
"phantomjs run-qunit.js http://localhost:8080/test.html|tail -1")))
(add-hook 'after-save-hook 'run-phantomjs)
@zkessin
zkessin / sync.coffee
Created September 6, 2012 12:42
Backbone Mock Sync
Backbone.sync = (method, collection, {url: url}) ->
collection.reset(My.Sync.data[url])
myModel.on("xyzzy", function () {
alert("XYZZY");
});
myModel.trigger("xyzzy");
_.map([1,2,3,4], function (x) {return x*x;}) //> [1,4, 9, 16]