-
Notifications
You must be signed in to change notification settings - Fork 701
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JsOptions test, use 3.14 as min required cabal version
- Loading branch information
Showing
11 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
packages: . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Main where | ||
|
||
import Lib | ||
|
||
main :: IO () | ||
main = foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Test.Cabal.Prelude | ||
|
||
main = do | ||
skipUnlessJavaScript | ||
skipIfWindows "" | ||
setupAndCabalTest $ do | ||
skipUnlessGhcVersion ">= 9.12" | ||
res <- cabal' "v2-run" ["demo"] | ||
assertOutputContains "Hello definition!" res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//#OPTIONS: CPP | ||
|
||
function foo() { | ||
#ifdef PRINT_DEF | ||
console.log("Hello definition!"); | ||
#else | ||
console.log("Hello!"); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
cabal-version: 3.14 | ||
name: jsoptions | ||
version: 0 | ||
build-type: Simple | ||
|
||
library | ||
default-language: Haskell2010 | ||
exposed-modules: Lib | ||
build-depends: base | ||
|
||
if impl(javascript) | ||
js-sources: jsbits/lib.js | ||
js-options: -optJSP-DPRINT_DEF | ||
|
||
executable demo | ||
default-language: Haskell2010 | ||
main-is: Main.hs | ||
hs-source-dirs: demo | ||
build-depends: base, jsoptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# cabal v2-run | ||
Configuration is affected by the following files: | ||
- cabal.project | ||
Resolving dependencies... | ||
Build profile: -w ghc-<GHCVER> -O1 | ||
In order, the following will be built: | ||
- jsoptions-exe-0 (lib) (first run) | ||
- jsoptions-exe-0 (exe:demo) (first run) | ||
Configuring library for jsoptions-exe-0... | ||
Preprocessing library for jsoptions-exe-0... | ||
Building library for jsoptions-exe-0... | ||
Configuring executable 'demo' for jsoptions-exe-0... | ||
Preprocessing executable 'demo' for jsoptions-exe-0... | ||
Building executable 'demo' for jsoptions-exe-0... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Test.Cabal.Prelude | ||
|
||
main = do | ||
skipIfJavaScript | ||
cabalTest $ do | ||
-- Ensure the field `js-options` does not raise issues | ||
res <- cabal' "v2-run" ["demo"] | ||
assertOutputContains "foo_fallback" res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{-# LANGUAGE CPP #-} | ||
module Lib where | ||
|
||
#if defined(javascript_HOST_ARCH) | ||
foreign import javascript foo :: IO () | ||
#else | ||
foo :: IO () | ||
foo = putStrLn "foo_fallback" | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters