File: test-hslua-list.hs

package info (click to toggle)
haskell-hslua-list 1.1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 116 kB
  • sloc: ansic: 349; haskell: 44; makefile: 6
file content (34 lines) | stat: -rw-r--r-- 914 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
34
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications    #-}
{-|
Module      : Main
Copyright   : © 2021-2024 Albert Krewinkel
License     : MIT
Maintainer  : Albert Krewinkel <tarleb@hslua.org>

Tests for the list type.
-}
module Main (main) where

import HsLua.Core as Lua
import HsLua.List
import Test.Tasty (defaultMain, testGroup)
import Test.Tasty.Lua (translateResultsFromFile)

main :: IO ()
main = do
  listTests <- run @Lua.Exception $ do
    openlibs
    -- Init default List module
    pushListModule *> setglobal "List"
    -- Create a custom List type with constructor "CustomList"
    pushHaskellFunction $ do
      settop 1
      newListMetatable "CustomList" (pure ())
      setmetatable (nthBottom 1)
      return 1
    setglobal "CustomList"
    translateResultsFromFile "test/test-list.lua"

  defaultMain $ testGroup "hslua-list" [listTests]