From 83be9a528b0276743833407666b4abcc3a15274d Mon Sep 17 00:00:00 2001 From: Phil Freeman Date: Wed, 25 May 2016 10:55:37 -0700 Subject: [PATCH] Fix core-tests (#2162) * Fix core-tests * test psc-docs --- core-tests/.gitignore | 1 + core-tests/bower.json | 60 +++++++++++++++++++++ core-tests/test-everything.sh | 60 +++------------------ core-tests/tests/GenericDeriving.purs | 30 +++++++++++ core-tests/tests/Main.purs | 9 ++++ core-tests/tests/generic-deriving/Main.purs | 27 ---------- 6 files changed, 107 insertions(+), 80 deletions(-) create mode 100644 core-tests/bower.json create mode 100755 core-tests/tests/GenericDeriving.purs create mode 100644 core-tests/tests/Main.purs delete mode 100755 core-tests/tests/generic-deriving/Main.purs diff --git a/core-tests/.gitignore b/core-tests/.gitignore index d7d596db5a..ec714d16e2 100644 --- a/core-tests/.gitignore +++ b/core-tests/.gitignore @@ -1,2 +1,3 @@ +core-docs.md bower_components/ output/ diff --git a/core-tests/bower.json b/core-tests/bower.json new file mode 100644 index 0000000000..253aaedcf2 --- /dev/null +++ b/core-tests/bower.json @@ -0,0 +1,60 @@ +{ + "name": "core-tests", + "homepage": "https://github.com/purescript/purescript", + "authors": [ + "Phil Freeman " + ], + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "dependencies": { + "purescript-arrays": "#8c9ada5762", + "purescript-bifunctors": "#9e3b2864ce", + "purescript-console": "#db29da9aca", + "purescript-const": "#cf538a65d8", + "purescript-contravariant": "#9ae6d7c99c", + "purescript-control": "#97096c7e26", + "purescript-distributive": "#ba81c64ffd", + "purescript-eff": "#dbd6c4a415", + "purescript-either": "#54f4efd423", + "purescript-enums": "#9332412e52", + "purescript-exceptions": "#522a0cea50", + "purescript-exists": "#e828c8341e", + "purescript-foldable-traversable": "#df37787855", + "purescript-foreign": "#64890cbbdb", + "purescript-free": "#f8ab7c5f05", + "purescript-functions": "#e417541936", + "purescript-functor-coproducts": "#7654d9dea4", + "purescript-generics": "#d09cb16ca3", + "purescript-globals": "#113ee398be", + "purescript-graphs": "#0b7089afa2", + "purescript-identity": "#204ac5f46a", + "purescript-inject": "#3ae4880bad", + "purescript-integers": "#58d7605dd5", + "purescript-lazy": "#bf4b34d673", + "purescript-maps": "#d9e4c6599a", + "purescript-math": "#99797b6494", + "purescript-maybe": "#1b60a07038", + "purescript-monoid": "#a8c8bb9d73", + "purescript-parallel": "#c7296ab008", + "purescript-prelude": "#318ee857bd", + "purescript-profunctor": "#a649126cea", + "purescript-proxy": "#c494b11bd7", + "purescript-quickcheck": "#4a15c93f12", + "purescript-random": "#68314c21e2", + "purescript-refs": "#f47e1059a3", + "purescript-semirings": "#c40efda15f", + "purescript-sets": "#1eaabf177f", + "purescript-st": "#077d9a2d7e", + "purescript-strings": "#87dd5f1694", + "purescript-tailrec": "#3c11db00ba", + "purescript-transformers": "#2d0a471ce4", + "purescript-tuples": "#4fe689ef93", + "purescript-unfoldable": "#e2382f30d8", + "purescript-validation": "#f43ff0fbdd" + } +} diff --git a/core-tests/test-everything.sh b/core-tests/test-everything.sh index 6aa0ebf1ea..4d0602448b 100755 --- a/core-tests/test-everything.sh +++ b/core-tests/test-everything.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e @@ -18,62 +18,16 @@ if [ "$force_reinstall" = "true" ] && [ -d "bower_components" ]; then rm -r bower_components fi -bower i \ - purescript-prelude \ - purescript-eff \ - purescript-st \ - purescript-integers \ - purescript-functions \ - purescript-console \ - purescript-profunctor \ - purescript-contravariant \ - purescript-parallel \ - purescript-control \ - purescript-tailrec \ - purescript-maps \ - purescript-free \ - purescript-transformers \ - purescript-exists \ - purescript-monoid \ - purescript-either \ - purescript-maybe \ - purescript-inject \ - purescript-graphs \ - purescript-enums \ - purescript-unfoldable \ - purescript-coproducts \ - purescript-lazy \ - purescript-distributive \ - purescript-identity \ - purescript-bifunctors \ - purescript-const \ - purescript-sets \ - purescript-quickcheck \ - purescript-foreign \ - purescript-foldable-traversable \ - purescript-tuples \ - purescript-strings \ - purescript-arrays \ - purescript-random \ - purescript-refs \ - purescript-globals \ - purescript-exceptions \ - purescript-validation \ - purescript-parallel \ - purescript-proxy \ - purescript-semirings \ - purescript-math \ - purescript-generics +# todo : fix this once core libraries reach 1.0 +yes 1 | bower i if [ "$force_recompile" = "true" ] && [ -d "output" ]; then echo "Recompiling..." rm -r output fi -../dist/build/psc/psc tests/*/*.purs \ - 'bower_components/purescript-*/src/**/*.purs' \ - --ffi 'bower_components/purescript-*/src/**/*.js' +stack exec psc 'tests/**/*.purs' 'bower_components/purescript-*/src/**/*.purs' -../dist/build/psc-docs/psc-docs tests/*/*.purs \ - 'bower_components/purescript-*/src/**/*.purs' \ - > full-core-docs.md +stack exec psc-docs 'bower_components/purescript-*/src/**/*.purs' > core-docs.md + +NODE_PATH=output node -e "require('Test.Main').main()" diff --git a/core-tests/tests/GenericDeriving.purs b/core-tests/tests/GenericDeriving.purs new file mode 100755 index 0000000000..f8e229c70a --- /dev/null +++ b/core-tests/tests/GenericDeriving.purs @@ -0,0 +1,30 @@ +module Test.GenericDeriving where + +import Prelude + +import Control.Monad.Eff (Eff) +import Control.Monad.Eff.Console (CONSOLE, log, logShow) +import Data.Generic (class Generic, gShow, gEq) +import Partial.Unsafe (unsafePartial) + +data Empty + +derive instance genericEmpty :: Partial => Generic Empty + +data A a + = A Number String + | B Int + | C (Array (A a)) + | D { "asgård" :: a } + | E Empty + +derive instance genericA :: (Partial, Generic b) => Generic (A b) + +newtype X b = X b + +derive instance genericX :: Generic (X String) + +main :: forall eff. Eff (console :: CONSOLE | eff) Unit +main = unsafePartial do + log $ gShow (D { "asgård": C [ A 1.0 "test", B 42, D { "asgård": true } ] }) + logShow $ gEq (C [B 0]) (C [B 0] :: A Empty) diff --git a/core-tests/tests/Main.purs b/core-tests/tests/Main.purs new file mode 100644 index 0000000000..8cd7b682cc --- /dev/null +++ b/core-tests/tests/Main.purs @@ -0,0 +1,9 @@ +module Test.Main where + +import Prelude +import Control.Monad.Eff (Eff) +import Control.Monad.Eff.Console (CONSOLE) +import Test.GenericDeriving as GenericDeriving + +main :: forall eff. Eff (console :: CONSOLE | eff) Unit +main = GenericDeriving.main diff --git a/core-tests/tests/generic-deriving/Main.purs b/core-tests/tests/generic-deriving/Main.purs deleted file mode 100755 index c98cea4f24..0000000000 --- a/core-tests/tests/generic-deriving/Main.purs +++ /dev/null @@ -1,27 +0,0 @@ -module GenericDeriving where - -import Prelude - -import Control.Monad.Eff (Eff) -import Control.Monad.Eff.Console (CONSOLE, log) -import Data.Generic - -data Void - -derive instance genericVoid :: Generic Void - -data A a - = A Number String - | B Int - | C (Array (A a)) - | D { "asgård" :: a } - | E Void - -derive instance genericA :: (Generic b) => Generic (A b) - -newtype X b = X b - -derive instance genericX :: Generic (X String) - -main :: forall eff. Eff (console :: CONSOLE | eff) Unit -main = log (gShow (D { "asgård": C [ A 1.0 "test", B 42, D { "asgård": true } ] }))