1 /*
2  * Hunt - A high-level D Programming Language Web framework that encourages rapid development and clean, pragmatic design.
3  *
4  * Copyright (C) 2015-2019, HuntLabs
5  *
6  * Website: https://www.huntlabs.net/
7  *
8  * Licensed under the Apache-2.0 License.
9  *
10  */
11 
12 module hunt.framework.view.algo.Tests;
13 
14 
15 import hunt.framework.view.algo.Wrapper;
16 import hunt.framework.view.Uninode;
17 import hunt.logging;
18 
19 
20 Function[string] globalTests()
21 {
22     return cast(immutable)
23         [
24             "defined":   wrapper!defined,
25             "undefined": wrapper!undefined,
26             "number":    wrapper!number,
27             "list":      wrapper!list,
28             "dict":      wrapper!dict,
29         ];
30 }
31 
32 
33 bool defined(UniNode value)
34 {
35     return value.kind != UniNode.Kind.nil;
36 }
37 
38 
39 bool undefined(UniNode value)
40 {
41     return value.kind == UniNode.Kind.nil;
42 }
43 
44 
45 bool number(UniNode value)
46 {
47     version(HUNT_VIEW_DEBUG) logDebug(value," kind :",value.kind);
48     return value.isNumericNode;
49 }
50 
51 
52 bool list(UniNode value)
53 {
54     version(HUNT_VIEW_DEBUG) logDebug(value," kind :",value.kind);
55     return value.kind == UniNode.Kind.array;
56 }
57 
58 
59 bool dict(UniNode value)
60 {
61     return value.kind == UniNode.Kind.object;
62 }