File: test-citation.lua

package info (click to toggle)
haskell-pandoc-lua-marshal 0.2.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 364 kB
  • sloc: haskell: 2,659; makefile: 6
file content (111 lines) | stat: -rw-r--r-- 3,179 bytes parent folder | download | duplicates (2)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
--
-- Tests for the pandoc types module
--
local tasty = require 'tasty'

local group = tasty.test_group
local test = tasty.test_case
local assert = tasty.assert

return {
  group 'Citation' {
    test('can be cloned', function ()
      local cit = Citation('leibniz', AuthorInText)
      local cloned = cit:clone()
      cit.id = 'newton'
      assert.are_same(cloned.id, 'leibniz')
      assert.are_same(cit.id, 'newton')
      assert.are_same(cit.mode, cloned.mode)
    end),
    group 'field `id`' {
      test('can be read', function ()
        assert.are_equal(
          Citation('einstein1905', 'NormalCitation').id,
          'einstein1905'
        )
      end),
      test('can be set', function ()
        local c = Citation('einstein1905', 'NormalCitation')
        c.id = 'Poincaré1905'
        assert.are_equal(c, Citation('Poincaré1905', 'NormalCitation'))
      end)
    },
    group 'field `mode`' {
      test('can be read', function ()
        assert.are_equal(
          Citation('einstein1905', 'NormalCitation').mode,
          'NormalCitation'
        )
      end),
      test('can be set', function ()
        local c = Citation('Poincaré1905', 'NormalCitation')
        c.mode = 'AuthorInText'
        assert.are_equal(c, Citation('Poincaré1905', 'AuthorInText'))
      end)
    },
    group 'field `prefix`' {
      test('can be read', function ()
        assert.are_same(
          Citation('einstein1905', 'NormalCitation', {'x'}).prefix,
          {Str 'x'}
        )
      end),
      test('can be set', function ()
        local c = Citation('Poincaré1905', 'NormalCitation')
        c.prefix = {'y'}
        assert.are_equal(
          c,
          Citation('Poincaré1905', 'NormalCitation', {'y'})
        )
      end),
    },
    group 'field `suffix`' {
      test('can be read', function ()
        assert.are_same(
          Citation('einstein1905', 'NormalCitation', {}, 'is great').suffix,
          {Str 'is', Space(), Str 'great'}
        )
      end),
      test('can be set', function ()
        local c = Citation('Poincaré1905', 'NormalCitation')
        c.suffix = {'why'}
        assert.are_equal(
          c,
          Citation('Poincaré1905', 'NormalCitation', {}, {'why'})
        )
      end),
    },
    group 'field `note_num`' {
      test('can be read', function ()
        assert.are_equal(
          Citation('einstein1905', 'NormalCitation', {}, {}, 7).note_num,
          7
        )
      end),
      test('can be set', function ()
        local c = Citation('Poincaré1905', 'NormalCitation')
        c.note_num = 23
        assert.are_equal(
          c,
          Citation('Poincaré1905', 'NormalCitation', {}, {}, 23)
        )
      end),
    },
    group 'field `hash`' {
      test('can be read', function ()
        assert.are_equal(
          Citation('einstein1905', 'NormalCitation', {}, {}, 0, 5).hash,
          5
        )
      end),
      test('can be set', function ()
        local c = Citation('Poincaré1905', 'NormalCitation')
        c.hash = 23
        assert.are_equal(
          c,
          Citation('Poincaré1905', 'NormalCitation', {}, {}, 0, 23)
        )
      end)
    }
  }
}