1 /**
2   * Description of global tests
3   *
4   * Copyright:
5   *     Copyright (c) 2018, Maxim Tyapkin.
6   * Authors:
7   *     Maxim Tyapkin
8   * License:
9   *     This software is licensed under the terms of the BSD 3-clause license.
10   *     The full terms of the license can be found in the LICENSE.md file.
11   */
12 
13 module djinja.algo.tests;
14 
15 private
16 {
17     import djinja.algo.wrapper;
18     import djinja.uninode;
19 }
20 
21 
22 Function[string] globalTests()
23 {
24     return cast(immutable)
25         [
26             "defined":   wrapper!defined,
27             "undefined": wrapper!undefined,
28             "number":    wrapper!number,
29             "list":      wrapper!list,
30             "dict":      wrapper!dict,
31         ];
32 }
33 
34 
35 bool defined(UniNode value)
36 {
37     return value.kind != UniNode.Kind.nil;
38 }
39 
40 
41 bool undefined(UniNode value)
42 {
43     return value.kind == UniNode.Kind.nil;
44 }
45 
46 
47 bool number(UniNode value)
48 {
49     return value.isNumericNode;
50 }
51 
52 
53 bool list(UniNode value)
54 {
55     return value.kind == UniNode.Kind.array;
56 }
57 
58 
59 bool dict(UniNode value)
60 {
61     return value.kind == UniNode.Kind.object;
62 }