File: WarnTests.hs

package info (click to toggle)
haskell-hslua-core 2.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 288 kB
  • sloc: haskell: 2,243; makefile: 3
file content (33 lines) | stat: -rw-r--r-- 890 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{-# LANGUAGE OverloadedStrings #-}
{-|
Module      :  HsLua.Core.WarnTests
Copyright   :  © 2017-2024 Albert Krewinkel
License     :  MIT

Maintainer  :  Albert Krewinkel <tarleb@hslua.org>

Check that setting hook for warning messages works.
-}
module HsLua.Core.WarnTests (tests) where

import HsLua.Core
import Test.Tasty.HsLua ((=:), shouldBeResultOf)
import Test.Tasty (TestTree, testGroup)

-- | Specifications for Attributes parsing functions.
tests :: TestTree
tests = testGroup "Warn"
  [ "warnings get handled" =:
    Just "Hi Mom!" `shouldBeResultOf` do
      openlibs
      setwarnf' $ \msg -> do
        pushstring msg
        setfield registryindex "hslua testing"
      stat <- dostring "warn('Hi', ' ', 'Mom!')"
      case stat of
        OK -> do
          getfield registryindex "hslua testing"
          tostring top
        _  -> do
          throwErrorAsException
  ]