packages feed

quickjs-hs 0.1.2.2 → 0.1.2.3

raw patch · 4 files changed

+19/−6 lines, 4 files

Files

ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for quickjs-hs +### 0.1.2.3++* Fix for infinite loop caused by incorrect defintion of SomeJSRuntimeException+ ### 0.1.2.2  * Bumped the quickjs library to release 2020-09-06
quickjs-hs.cabal view
@@ -1,6 +1,6 @@ cabal-version:  1.12 name:           quickjs-hs-version:        0.1.2.2+version:        0.1.2.3 homepage:       https://github.com/goodlyrottenapple/quickjs-hs#readme bug-reports:    https://github.com/goodlyrottenapple/quickjs-hs/issues author:         Sam Balco
src/Quickjs/Error.hs view
@@ -18,10 +18,7 @@ instance Show SomeJSRuntimeException where     show (SomeJSRuntimeException e) = show e -instance Exception SomeJSRuntimeException where-    toException = jsRuntimeExceptionToException-    fromException = jsRuntimeExceptionFromException-+instance Exception SomeJSRuntimeException  jsRuntimeExceptionToException :: Exception e => e -> SomeException jsRuntimeExceptionToException = toException . SomeJSRuntimeException
test/Spec.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-}  module Main where@@ -10,11 +12,13 @@ import qualified Test.QuickCheck.Monadic as QC import           Data.Aeson              (Value(..)) import           Control.Monad.IO.Class  (liftIO)-import           Control.Monad.Catch     (SomeException, MonadCatch(..))+import           Control.Monad.Catch     (try, SomeException, MonadCatch(..)) import           Data.Text               (pack) import qualified Data.HashMap.Strict            as HM import qualified Data.Vector             as V import           Quickjs+import Test.HUnit (assertFailure)+import Quickjs.Error (SomeJSRuntimeException)   eval_1_plus_2 :: Assertion@@ -22,6 +26,13 @@   v <- eval "1 + 2;"   liftIO $ v @?= Number 3 ++eval_throw :: Assertion+eval_throw = quickjsMultithreaded $+  try (eval "throw 'Error'") >>= \case+    Left (_ :: SomeJSRuntimeException) -> return ()+    Right _ -> liftIO $ assertFailure "should fail with an Exception..."+ genText = do    k <- QC.choose (0,200)    pack <$> QC.vectorOf k (QC.oneof $ map pure $ ['0'..'~'])@@ -63,6 +74,7 @@   testGroup "Quickjs"     [ testCase "empty quickjs call" (quickjsMultithreaded $ pure ())     , testCase "eval '1 + 2;'" eval_1_plus_2+    , testCase "eval throw" eval_throw     , testProperty "marshalling Value to JSValue and back" marshall_to_from_JSValue     ]