purescript: add test that compiles & runs a minimal module
This ensures the compiler actually works. `console.log` is wrapped in a purescript function and everything is run with nodejs.
This commit is contained in:
parent
2156d43659
commit
f71bdfd5ab
@ -1,4 +1,4 @@
|
|||||||
{ stdenv, fetchurl, zlib, gmp, ncurses5, lib }:
|
{ stdenv, pkgs, fetchurl, zlib, gmp, ncurses5, lib }:
|
||||||
|
|
||||||
# from justinwoo/easy-purescript-nix
|
# from justinwoo/easy-purescript-nix
|
||||||
# https://github.com/justinwoo/easy-purescript-nix/blob/d383972c82620a712ead4033db14110497bc2c9c/purs.nix
|
# https://github.com/justinwoo/easy-purescript-nix/blob/d383972c82620a712ead4033db14110497bc2c9c/purs.nix
|
||||||
@ -50,6 +50,11 @@ in stdenv.mkDerivation rec {
|
|||||||
mkdir -p $out/etc/bash_completion.d/
|
mkdir -p $out/etc/bash_completion.d/
|
||||||
$PURS --bash-completion-script $PURS > $out/etc/bash_completion.d/purs-completion.bash
|
$PURS --bash-completion-script $PURS > $out/etc/bash_completion.d/purs-completion.bash
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
passthru.tests = {
|
||||||
|
minimal-module = pkgs.callPackage ./test-minimal-module {};
|
||||||
|
};
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with stdenv.lib; {
|
||||||
description = "A strongly-typed functional programming language that compiles to JavaScript";
|
description = "A strongly-typed functional programming language that compiles to JavaScript";
|
||||||
homepage = http://www.purescript.org/;
|
homepage = http://www.purescript.org/;
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
"use strict"
|
||||||
|
|
||||||
|
exports.log = function (s) {
|
||||||
|
return function () {
|
||||||
|
console.log(s);
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
};
|
@ -0,0 +1,9 @@
|
|||||||
|
module Main where
|
||||||
|
|
||||||
|
foreign import data Effect :: Type -> Type
|
||||||
|
data Unit = Unit
|
||||||
|
|
||||||
|
foreign import log :: String -> Effect Unit
|
||||||
|
|
||||||
|
main :: Effect Unit
|
||||||
|
main = log "hello world"
|
@ -0,0 +1,11 @@
|
|||||||
|
{ runCommand, purescript, nodejs }:
|
||||||
|
|
||||||
|
runCommand "purescript-test-minimal-module" {} ''
|
||||||
|
${purescript}/bin/purs compile -o ./output ${./.}/Main.purs
|
||||||
|
|
||||||
|
echo 'require("./output/Main/index.js").main()' > node.js
|
||||||
|
|
||||||
|
${nodejs}/bin/node node.js | grep "hello world" || echo "did not output hello world"
|
||||||
|
|
||||||
|
touch $out
|
||||||
|
''
|
Loading…
x
Reference in New Issue
Block a user