conjur-asset-ui-api 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/.git-hooks/pre_commit/ensure_livescript_compiled.rb +31 -0
  3. data/.git-hooks/pre_commit/trailing_whitespace.rb +26 -0
  4. data/.gitignore +20 -0
  5. data/.overcommit.yml +5 -0
  6. data/.project +18 -0
  7. data/Gemfile +8 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +41 -0
  10. data/Rakefile +1 -0
  11. data/compile_ls +2 -0
  12. data/conjur-asset-ui.gemspec +36 -0
  13. data/lib/conjur-asset-ui-version.rb +7 -0
  14. data/lib/conjur-asset-ui.rb +7 -0
  15. data/lib/conjur/audit/follower.rb +63 -0
  16. data/lib/conjur/audit/humanizer.rb +53 -0
  17. data/lib/conjur/audit/tableizer.rb +55 -0
  18. data/lib/conjur/command/ui.rb +38 -0
  19. data/lib/conjur/webserver/api_proxy.rb +94 -0
  20. data/lib/conjur/webserver/audit_stream.rb +92 -0
  21. data/lib/conjur/webserver/authorize.rb +28 -0
  22. data/lib/conjur/webserver/conjur_info.rb +33 -0
  23. data/lib/conjur/webserver/home.rb +36 -0
  24. data/lib/conjur/webserver/login.rb +50 -0
  25. data/lib/conjur/webserver/server.rb +111 -0
  26. data/livescript/views/audit.ls +124 -0
  27. data/public/css/bootstrap.css +7 -0
  28. data/public/css/styles.less +400 -0
  29. data/public/fonts/glyphicons-halflings-regular.eot +0 -0
  30. data/public/fonts/glyphicons-halflings-regular.svg +229 -0
  31. data/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  32. data/public/fonts/glyphicons-halflings-regular.woff +0 -0
  33. data/public/images/conjur-logo.svg +26 -0
  34. data/public/images/icon-client-pc.svg +12 -0
  35. data/public/images/icon-environment.png +0 -0
  36. data/public/images/icon-person.svg +12 -0
  37. data/public/images/icon-service-dots.svg +13 -0
  38. data/public/images/icon-variable.png +0 -0
  39. data/public/index.html +121 -0
  40. data/public/js/lib/JSXTransformer.js +10862 -0
  41. data/public/js/lib/async.js +958 -0
  42. data/public/js/lib/backbone.js +2 -0
  43. data/public/js/lib/bootstrap.js +6 -0
  44. data/public/js/lib/date.extensions.js +141 -0
  45. data/public/js/lib/less.js +16 -0
  46. data/public/js/lib/moment.js +7768 -0
  47. data/public/js/lib/pace.js +2 -0
  48. data/public/js/lib/prelude-browser-min.js +1 -0
  49. data/public/js/lib/react-with-addons.js +15505 -0
  50. data/public/js/lib/react.js +14469 -0
  51. data/public/js/lib/sorted-set.no-require.js +1170 -0
  52. data/public/js/lib/sorted-set.no-require.js.txt +6 -0
  53. data/public/js/lib/underscore-min.js +6 -0
  54. data/public/js/lib/underscore.string.min.js +1 -0
  55. data/public/js/main.js +353 -0
  56. data/public/js/models/namespace.js +6 -0
  57. data/public/js/models/policyList.js +10 -0
  58. data/public/js/models/record.js +26 -0
  59. data/public/js/models/resourceList.js +61 -0
  60. data/public/js/models/userList.js +16 -0
  61. data/public/js/models/variableList.js +12 -0
  62. data/public/js/views/audit.js +191 -0
  63. data/public/js/views/dashboard.js +35 -0
  64. data/public/js/views/generic.js +42 -0
  65. data/public/js/views/group.js +32 -0
  66. data/public/js/views/groups.js +18 -0
  67. data/public/js/views/host.js +40 -0
  68. data/public/js/views/hosts.js +18 -0
  69. data/public/js/views/layer.js +63 -0
  70. data/public/js/views/layers.js +18 -0
  71. data/public/js/views/mixins/search.js +9 -0
  72. data/public/js/views/namespaces.js +40 -0
  73. data/public/js/views/navSearch.js +16 -0
  74. data/public/js/views/permissions.js +91 -0
  75. data/public/js/views/policies.js +17 -0
  76. data/public/js/views/policy.js +23 -0
  77. data/public/js/views/resource.js +23 -0
  78. data/public/js/views/role.js +18 -0
  79. data/public/js/views/searchResults.js +146 -0
  80. data/public/js/views/time.js +14 -0
  81. data/public/js/views/user.js +22 -0
  82. data/public/js/views/users.js +18 -0
  83. data/public/js/views/variable.js +41 -0
  84. data/public/js/views/variables.js +18 -0
  85. data/vendor/prelude-ls/.gitignore +2 -0
  86. data/vendor/prelude-ls/.travis.yml +3 -0
  87. data/vendor/prelude-ls/CHANGELOG.md +81 -0
  88. data/vendor/prelude-ls/LICENSE +22 -0
  89. data/vendor/prelude-ls/Makefile +50 -0
  90. data/vendor/prelude-ls/README.md +15 -0
  91. data/vendor/prelude-ls/browser/prelude-browser-min.js +1 -0
  92. data/vendor/prelude-ls/browser/prelude-browser.js +1172 -0
  93. data/vendor/prelude-ls/lib/Func.js +40 -0
  94. data/vendor/prelude-ls/lib/List.js +602 -0
  95. data/vendor/prelude-ls/lib/Num.js +129 -0
  96. data/vendor/prelude-ls/lib/Obj.js +153 -0
  97. data/vendor/prelude-ls/lib/Str.js +68 -0
  98. data/vendor/prelude-ls/lib/index.js +164 -0
  99. data/vendor/prelude-ls/package.json +50 -0
  100. data/vendor/prelude-ls/package.ls +46 -0
  101. data/vendor/prelude-ls/src/Func.ls +17 -0
  102. data/vendor/prelude-ls/src/List.ls +299 -0
  103. data/vendor/prelude-ls/src/Num.ls +83 -0
  104. data/vendor/prelude-ls/src/Obj.ls +61 -0
  105. data/vendor/prelude-ls/src/Str.ls +32 -0
  106. data/vendor/prelude-ls/src/index.ls +56 -0
  107. data/vendor/prelude-ls/test/Func.ls +36 -0
  108. data/vendor/prelude-ls/test/List.ls +751 -0
  109. data/vendor/prelude-ls/test/Num.ls +258 -0
  110. data/vendor/prelude-ls/test/Obj.ls +145 -0
  111. data/vendor/prelude-ls/test/Prelude.ls +49 -0
  112. data/vendor/prelude-ls/test/Str.ls +208 -0
  113. data/vendor/prelude-ls/test/browser.html +5 -0
  114. metadata +328 -0
@@ -0,0 +1,61 @@
1
+ values = (object) ->
2
+ [x for , x of object]
3
+
4
+ keys = (object) ->
5
+ [x for x of object]
6
+
7
+ pairs-to-obj= (object) ->
8
+ {[x.0, x.1] for x in object}
9
+
10
+ obj-to-pairs = (object) ->
11
+ [[key, value] for key, value of object]
12
+
13
+ lists-to-obj= (keys, values) -->
14
+ {[key, values[i]] for key, i in keys}
15
+
16
+ obj-to-lists = (objectect) ->
17
+ keys = []
18
+ values = []
19
+ for key, value of objectect
20
+ keys.push key
21
+ values.push value
22
+ [keys, values]
23
+
24
+
25
+ empty = (object) ->
26
+ for x of object then return false
27
+ true
28
+
29
+ each = (f, object) -->
30
+ for , x of object then f x
31
+ object
32
+
33
+ map = (f, object) -->
34
+ {[k, f x] for k, x of object}
35
+
36
+ compact = (object) -->
37
+ {[k, x] for k, x of object when x}
38
+
39
+ filter = (f, object) -->
40
+ {[k, x] for k, x of object when f x}
41
+
42
+ reject = (f, object) -->
43
+ {[k, x] for k, x of object when not f x}
44
+
45
+ partition = (f, object) -->
46
+ passed = {}
47
+ failed = {}
48
+ for k, x of object
49
+ (if f x then passed else failed)[k] = x
50
+ [passed, failed]
51
+
52
+ find = (f, object) -->
53
+ for , x of object when f x then return x
54
+ void
55
+
56
+ module.exports = {
57
+ values, keys,
58
+ pairs-to-obj, obj-to-pairs, lists-to-obj, obj-to-lists,
59
+
60
+ empty, each, map, filter, compact, reject, partition, find,
61
+ }
@@ -0,0 +1,32 @@
1
+ split = (sep, str) -->
2
+ str.split sep
3
+
4
+ join = (sep, xs) -->
5
+ xs.join sep
6
+
7
+ lines = (str) ->
8
+ return [] unless str.length
9
+ str.split '\n'
10
+
11
+ unlines = (.join '\n')
12
+
13
+ words = (str) ->
14
+ return [] unless str.length
15
+ str.split /[ ]+/
16
+
17
+ unwords = (.join ' ')
18
+
19
+ chars = (.split '')
20
+
21
+ unchars = (.join '')
22
+
23
+ reverse = (str) ->
24
+ str.split '' .reverse!.join ''
25
+
26
+ repeat = (n, str) -->
27
+ out = [str for til n]
28
+ out.join ''
29
+
30
+ module.exports = {
31
+ split, join, lines, unlines, words, unwords, chars, unchars, reverse, repeat,
32
+ }
@@ -0,0 +1,56 @@
1
+ require! [
2
+ './Func.js'
3
+ './List.js'
4
+ './Obj.js'
5
+ './Str.js'
6
+ './Num.js'
7
+ ]
8
+
9
+ id = (x) -> x
10
+
11
+ is-type = (type, x) --> typeof! x is type
12
+
13
+ replicate = (n, x) -->
14
+ [x for til n]
15
+
16
+
17
+ Str <<< List{
18
+ empty, slice, take, drop, split-at, take-while, drop-while, span, break-str: break-list
19
+ }
20
+
21
+ prelude = {
22
+ Func, List, Obj, Str, Num,
23
+ id, is-type
24
+ replicate,
25
+ }
26
+ prelude <<< List{
27
+ each, map, filter, compact, reject, partition, find,
28
+ head, first, tail, last, initial, empty,
29
+ reverse, difference, intersection, union, count-by, group-by,
30
+ fold, foldl, fold1, foldl1, foldr, foldr1, unfoldr, and-list, or-list,
31
+ any, all, unique, sort, sort-with, sort-by, sum, product, mean, average,
32
+ concat, concat-map, flatten,
33
+ maximum, minimum, scan, scanl, scan1, scanl1, scanr, scanr1,
34
+ slice, take, drop, split-at, take-while, drop-while, span, break-list,
35
+ zip, zip-with, zip-all, zip-all-with,
36
+ }
37
+ prelude <<< Func{
38
+ apply, curry, flip, fix,
39
+ }
40
+ prelude <<< Str{
41
+ split, join, lines, unlines, words, unwords, chars, unchars
42
+ }
43
+ # not importing all of Obj's functions
44
+ prelude <<< Obj{
45
+ values, keys,
46
+ pairs-to-obj, obj-to-pairs, lists-to-obj, obj-to-lists,
47
+ }
48
+ prelude <<< Num{
49
+ max, min, negate, abs, signum, quot, rem, div, mod, recip,
50
+ pi, tau, exp, sqrt, ln, pow, sin, tan, cos, acos, asin, atan, atan2,
51
+ truncate, round, ceiling, floor, is-it-NaN, even, odd, gcd, lcm,
52
+ }
53
+
54
+ prelude.VERSION = '1.0.3'
55
+
56
+ module.exports = prelude
@@ -0,0 +1,36 @@
1
+ {apply, curry, flip, fix} = require '..' .Func
2
+ {equal: eq, deep-equal: deep-eq, ok} = require 'assert'
3
+
4
+ suite 'apply' ->
5
+ test 'empty list' ->
6
+ f = -> 1
7
+ eq 1, apply f, []
8
+
9
+ test 'a couple of args' ->
10
+ eq 5, apply (+), [2 3]
11
+
12
+ test 'curried' ->
13
+ f = apply (+)
14
+ eq 5, f [2 3]
15
+
16
+ suite 'curry' ->
17
+ test 'simple function' ->
18
+ add = (x, y) -> x + y
19
+ add-curried = curry add
20
+ add-four = add-curried 4
21
+ eq 6 add-four 2
22
+
23
+ suite 'flip' ->
24
+ test 'minus op' ->
25
+ eq 10, (flip (-)) 5 15
26
+
27
+ suite 'fix' ->
28
+ test 'single arg' ->
29
+ eq 89, (fix (fib) -> (n) ->
30
+ | n <= 1 => 1
31
+ | otherwise => fib(n-1) + fib(n-2))(10)
32
+
33
+ test 'multi-arg variation' ->
34
+ eq 89, (fix (fib) -> (n, minus=0) ->
35
+ | (n - minus) <= 1 => 1
36
+ | otherwise => fib(n, minus+1) + fib(n, minus+2))(10)
@@ -0,0 +1,751 @@
1
+ {
2
+ id
3
+ Num: {even, odd, floor, is-it-NaN}
4
+ List: {
5
+ each, map, filter, compact, reject, partition, find,
6
+ head, first, tail, last, initial, empty,
7
+ reverse, difference, intersection, union, count-by, group-by,
8
+ fold, fold1, foldl, foldl1, foldr, foldr1, unfoldr, and-list, or-list,
9
+ any, all, unique, sort, sort-with, sort-by, sum, product, mean, average,
10
+ concat, concat-map, flatten,
11
+ maximum, minimum, scan, scan1, scanl, scanl1, scanr, scanr1,
12
+ slice, take, drop, split-at, take-while, drop-while, span, break-list,
13
+ zip, zip-with, zip-all, zip-all-with,
14
+ }
15
+ } = require '..'
16
+ {equal: eq, deep-equal: deep-eq, ok} = require 'assert'
17
+
18
+ suite 'each' ->
19
+ test 'empty list as input' ->
20
+ deep-eq [], each id, []
21
+
22
+ test 'side effects affect input (and thus result)' ->
23
+ deep-eq [[1],[2]] each (.pop!), [[1 5] [2 6]]
24
+
25
+ test 'curried' ->
26
+ f = each (.pop!)
27
+ deep-eq [[1],[2]], f [[1 5] [2 6]]
28
+
29
+ suite 'map' ->
30
+ test 'empty list as input' ->
31
+ deep-eq [], map id, []
32
+
33
+ test 'mapping over array' ->
34
+ deep-eq [2 3 4], map (+ 1), [1 2 3]
35
+
36
+ test 'curried' ->
37
+ f = map (+ 1)
38
+ deep-eq [2 3 4], f [1 2 3]
39
+
40
+ suite 'compact' ->
41
+ test 'empty list as input' ->
42
+ deep-eq [], compact []
43
+
44
+ test 'compacting array' ->
45
+ deep-eq [1 true 'ha'], compact [0 1 false true '' 'ha']
46
+
47
+ suite 'filter' ->
48
+ test 'empty list as input' ->
49
+ deep-eq [], filter id, []
50
+
51
+ test 'filtering array' ->
52
+ deep-eq [2, 4], filter even, [1 to 5]
53
+
54
+ test 'filter on true returns original list' ->
55
+ deep-eq [1 2 3], filter (-> true), [1 2 3]
56
+
57
+ test 'filter on false returns empty list' ->
58
+ deep-eq [], filter (-> false), [1 2 3]
59
+
60
+ test 'curried' ->
61
+ f = filter even
62
+ deep-eq [2, 4], f [1 to 5]
63
+
64
+ suite 'reject' ->
65
+ test 'empty list as input' ->
66
+ deep-eq [], reject id, []
67
+
68
+ test 'reject list' ->
69
+ deep-eq [1 3 5], reject even, [1 to 5]
70
+
71
+ test 'reject on true returns empty list' ->
72
+ deep-eq [], reject (-> true), [1 2 3]
73
+
74
+ test 'reject on true returns original list' ->
75
+ deep-eq [1 2 3], reject (-> false), [1 2 3]
76
+
77
+ test 'curried' ->
78
+ f = reject even
79
+ deep-eq [1 3 5], f [1 to 5]
80
+
81
+ suite 'partition' ->
82
+ test 'empty list as input' ->
83
+ deep-eq [[],[]], partition id, []
84
+
85
+ test 'partition list' ->
86
+ deep-eq [[76 88 77 90],[49 58 43]], partition (>60), [49 58 76 43 88 77 90]
87
+
88
+ test 'partition on true returns original list as passing, empty list as failing' ->
89
+ deep-eq [[1 2 3],[]], partition (-> true), [1 2 3]
90
+
91
+ test 'partition on false returns empty list as failing, empty list as passing' ->
92
+ deep-eq [[], [1 2 3]], partition (-> false), [1 2 3]
93
+
94
+ test 'curried' ->
95
+ f = partition (>60)
96
+ deep-eq [[76 88 77 90],[49 58 43]], f [49 58 76 43 88 77 90]
97
+
98
+ suite 'find' ->
99
+ test 'empty list as input' ->
100
+ eq void, find id, []
101
+
102
+ test 'find from list' ->
103
+ eq 4, find even, [3 1 4 8 6]
104
+
105
+ test 'finding nothing when function always false' ->
106
+ eq void, find (-> false), [1 2 3]
107
+
108
+ test 'find first item when function always true' ->
109
+ eq 1, find (-> true), [1 2 3]
110
+
111
+ test 'curried' ->
112
+ f = find even
113
+ eq 4, f [3 1 4 8 6]
114
+
115
+ suite 'list portions' ->
116
+ list = [1 2 3 4 5]
117
+
118
+ suite 'head' ->
119
+ test 'empty list as input' ->
120
+ eq void, head []
121
+
122
+ test 'list' ->
123
+ eq 1, head list
124
+
125
+ test 'first as alias' ->
126
+ eq first, head
127
+
128
+ suite 'tail' ->
129
+ test 'empty list as input' ->
130
+ eq void, tail []
131
+
132
+ test 'list' ->
133
+ deep-eq [2 3 4 5], tail list
134
+
135
+ test 'one element list' ->
136
+ deep-eq [], tail [1]
137
+
138
+ suite 'last' ->
139
+ test 'empty list as input' ->
140
+ eq void, last []
141
+
142
+ test 'list' ->
143
+ eq 5, last list
144
+
145
+ test 'one element list' ->
146
+ eq 1, last [1]
147
+
148
+ suite 'initial' ->
149
+ test 'empty list as input' ->
150
+ eq void, initial []
151
+
152
+ test 'list' ->
153
+ deep-eq [1 2 3 4], initial list
154
+
155
+ test 'one element list' ->
156
+ deep-eq [], initial [1]
157
+
158
+ suite 'empty' ->
159
+ test 'empty list as input' ->
160
+ ok empty []
161
+
162
+ test 'non-empty list as input' ->
163
+ ok not empty [1]
164
+
165
+ suite 'reverse' ->
166
+ test 'empty list as input' ->
167
+ deep-eq [], reverse []
168
+
169
+ test 'reverse list, it is unmodified' ->
170
+ list = [1 2 3 4 5]
171
+ deep-eq [5 4 3 2 1], reverse list
172
+ deep-eq [1 2 3 4 5], list
173
+
174
+ suite 'unique' ->
175
+ test 'empty list as input' ->
176
+ deep-eq [], unique []
177
+
178
+ test 'unique list' ->
179
+ deep-eq [1,2,3,4,5,6], unique [1 1 2 3 3 4 5 5 5 5 5 6 6 6 6]
180
+
181
+ suite 'fold' ->
182
+ test 'empty list as input' ->
183
+ eq 0, fold (+), 0, []
184
+
185
+ test 'list as input' ->
186
+ eq 12, fold (+), 0, [1 2 3 6]
187
+
188
+ test 'foldl is alias' ->
189
+ eq fold, foldl
190
+
191
+ test 'curried' ->
192
+ f = fold (+)
193
+ eq 12, f 0, [1 2 3 6]
194
+
195
+ g = fold (+), 0
196
+ eq 12 g [1 2 3 6]
197
+
198
+ suite 'fold1' ->
199
+ test 'empty list as input' ->
200
+ eq void, fold1 (+), []
201
+
202
+ test 'list as input' ->
203
+ eq 12, fold1 (+), [1 2 3 6]
204
+
205
+ test 'foldl1 as alais' ->
206
+ eq fold1, foldl1
207
+
208
+ test 'curried' ->
209
+ f = fold1 (+)
210
+ eq 12, f [1 2 3 6]
211
+
212
+ suite 'foldr' ->
213
+ test 'empty list as input' ->
214
+ eq 0, foldr (+), 0, []
215
+
216
+ test 'list as input' ->
217
+ eq -1, foldr (-), 9, [1 2 3 4]
218
+
219
+ test 'curried' ->
220
+ f = foldr (-)
221
+ eq -1, f 9, [1 2 3 4]
222
+
223
+ g = foldr (-), 9
224
+ eq -1, g [1 2 3 4]
225
+
226
+ suite 'foldr1' ->
227
+ test 'empty list as input' ->
228
+ eq void, foldr1 (+), []
229
+
230
+ test 'list as input' ->
231
+ eq -1, foldr1 (-), [1 2 3 4 9]
232
+
233
+ test 'curried' ->
234
+ f = foldr1 (-)
235
+ eq -1, f [1 2 3 4 9]
236
+
237
+ suite 'unfoldr' ->
238
+ test 'complex case' ->
239
+ deep-eq [10,9,8,7,6,5,4,3,2,1], unfoldr (-> if it == 0 then null else [it, it - 1]), 10
240
+
241
+ test 'returning null right away results in a one item list' ->
242
+ deep-eq [], unfoldr (-> null), 'a'
243
+
244
+ test 'curried' ->
245
+ f = unfoldr (-> if it == 0 then null else [it, it - 1])
246
+ deep-eq [10,9,8,7,6,5,4,3,2,1], f 10
247
+
248
+ suite 'concat' ->
249
+ test 'empty list as input' ->
250
+ deep-eq [], concat []
251
+
252
+ test 'multiple lists' ->
253
+ deep-eq [1,2,3,4,5,6], concat [[1 2] [3 4] [5 6]]
254
+
255
+ suite 'concat-map' ->
256
+ test 'empty list as input' ->
257
+ deep-eq [], concat-map id, []
258
+
259
+ test 'just using mapping' ->
260
+ deep-eq [1 2 3], concat-map (+ 1), [0 1 2]
261
+
262
+ test 'just using concatinating' ->
263
+ deep-eq [1 2 3], concat-map id, [[1],[2],[3]]
264
+
265
+ test 'using mapping and concatinating' ->
266
+ deep-eq [1,1,2,1,2,3], concat-map (-> [1 to it]), [1 2 3]
267
+
268
+ test 'curried' ->
269
+ f = concat-map (-> [1 to it])
270
+ deep-eq [1,1,2,1,2,3], f [1 2 3]
271
+
272
+ suite 'flatten' ->
273
+ test 'empty list as input' ->
274
+ deep-eq [], flatten []
275
+
276
+ test 'nested lists as input' ->
277
+ deep-eq [1,2,3,4,5], flatten [1, [[2], 3], [4, [[5]]]]
278
+
279
+ test 'lists with strings' ->
280
+ deep-eq ['a','b','c','d','e'], flatten ['a', [['b'], 'c'], ['d', [['e']]]]
281
+
282
+ suite 'difference' ->
283
+ test 'empty list(s) as input' ->
284
+ deep-eq [], difference []
285
+ deep-eq [], difference [] []
286
+
287
+ test 'subtract nothing' ->
288
+ deep-eq [1 2 3], difference [1 2 3]
289
+ deep-eq [1 2 3], difference [1 2 3] []
290
+
291
+ test 'subtract single element' ->
292
+ deep-eq [2 3], difference [1 2 3] [1]
293
+
294
+ test 'subtract multiple elements' ->
295
+ deep-eq [1 3 4], difference [1 2 3 4 5] [5 2 10] [9]
296
+
297
+ suite 'intersection' ->
298
+ test 'empty list(s) as input' ->
299
+ deep-eq [], intersection []
300
+ deep-eq [], intersection [] []
301
+
302
+ test 'no common elements' ->
303
+ deep-eq [],intersection [2 3] [9 8] [12 1] [99]
304
+
305
+ test 'some common elements' ->
306
+ deep-eq [1 2], intersection [1 2 3] [101 2 1 10] [2 1] [-1 0 1 2]
307
+
308
+ test 'all common elements' ->
309
+ deep-eq [1 2 3], intersection [1 2 3] [2 1 3] [3 1 2]
310
+
311
+ suite 'union' ->
312
+ test 'empty list(s) as input' ->
313
+ deep-eq [], union []
314
+ deep-eq [], union [] []
315
+
316
+ test 'list and empty list' ->
317
+ deep-eq [1 2 3], union [1 2 3] []
318
+
319
+ test 'with various' ->
320
+ deep-eq [1 5 7 3], union [1 5 7] [3 5] []
321
+
322
+ suite 'count-by' ->
323
+ test 'empty list as input' ->
324
+ deep-eq [], count-by id, []
325
+
326
+ test 'list of numbers' ->
327
+ deep-eq {4: 1, 6: 2}, count-by floor, [4.2, 6.1, 6.4]
328
+
329
+ test 'list of strings' ->
330
+ deep-eq {3: 2, 5: 1}, count-by (.length), <[ one two three ]>
331
+
332
+ test 'curried' ->
333
+ f = count-by floor
334
+ deep-eq {4: 1, 6: 2}, f [4.2, 6.1, 6.4]
335
+
336
+ suite 'group-by' ->
337
+ test 'empty list as input' ->
338
+ deep-eq [], group-by id, []
339
+
340
+ test 'list of numbers' ->
341
+ deep-eq {4: [4.2], 6: [6.1 6.4]}, group-by floor, [4.2, 6.1, 6.4]
342
+
343
+ test 'list of strings' ->
344
+ deep-eq {3: <[ one two ]>, 5: <[ three ]>}, group-by (.length), <[ one two three ]>
345
+
346
+ test 'curried' ->
347
+ f = group-by floor
348
+ deep-eq {4: [4.2], 6: [6.1 6.4]}, f [4.2, 6.1, 6.4]
349
+
350
+ suite 'and-list' ->
351
+ test 'empty list as input' ->
352
+ ok and-list []
353
+
354
+ test 'true' ->
355
+ ok and-list [true, 2 + 2 == 4]
356
+
357
+ test 'false' ->
358
+ ok not and-list [true true false true]
359
+
360
+ suite 'or-list' ->
361
+ test 'empty list as input' ->
362
+ ok not or-list []
363
+
364
+ test 'true' ->
365
+ ok or-list [false false false true false]
366
+
367
+ test 'false' ->
368
+ ok not or-list [false, 2 + 2 == 3]
369
+
370
+ suite 'any' ->
371
+ test 'empty list as input' ->
372
+ ok not any id, []
373
+
374
+ test 'true' ->
375
+ ok any even, [1 4 3]
376
+
377
+ test 'false' ->
378
+ ok not any even, [1 3 7 5]
379
+
380
+ test 'curried' ->
381
+ f = any even
382
+ ok f [1 4 3]
383
+
384
+ suite 'all' ->
385
+ test 'empty list as input' ->
386
+ ok all even, []
387
+
388
+ test 'true' ->
389
+ ok all even, [2 4 6]
390
+
391
+ test 'false' ->
392
+ ok not all even, [2 5 6]
393
+
394
+ test 'curried' ->
395
+ f = all even
396
+ ok f [2 4 6]
397
+
398
+ suite 'sort' ->
399
+ test 'empty list as input' ->
400
+ deep-eq [], sort []
401
+
402
+ test 'single digit numbers' ->
403
+ deep-eq [1,2,3,4,5,6], sort [3 1 5 2 4 6]
404
+
405
+ test 'multi digit numbers' ->
406
+ deep-eq [2,5,6,12,334,4999], sort [334 12 5 2 4999 6]
407
+
408
+ suite 'sort-with' ->
409
+ f = (x, y) ->
410
+ | x.length > y.length => 1
411
+ | x.length < y.length => -1
412
+ | otherwise => 0
413
+
414
+ test 'empty list as input' ->
415
+ deep-eq [], sort-with id, []
416
+
417
+ test 'complex case' ->
418
+ deep-eq ['one','two','three'], sort-with f, <[ three one two ]>
419
+
420
+ test 'curried' ->
421
+ g = sort-with f
422
+ deep-eq ['one','two','three'], g <[ three one two ]>
423
+
424
+ suite 'sort-by' ->
425
+ arr =
426
+ 'hey'
427
+ 'a'
428
+ 'there'
429
+ 'ha'
430
+
431
+ test 'empty list as input' ->
432
+ deep-eq [], sort-by id, []
433
+
434
+ test 'complex case' ->
435
+ deep-eq ['a', 'ha', 'hey', 'there'], sort-by (.length), arr
436
+
437
+ test 'curried' ->
438
+ f = sort-by (.length)
439
+ deep-eq ['a', 'ha', 'hey', 'there'], f arr
440
+
441
+ suite 'sum' ->
442
+ test 'empty list as input' ->
443
+ eq 0, sum []
444
+
445
+ test 'list as input' ->
446
+ eq 10, sum [1 2 3 4]
447
+
448
+ test 'negative numbers' ->
449
+ eq -2, sum [1 -2 3 -4]
450
+
451
+ suite 'product' ->
452
+ test 'empty list as input' ->
453
+ eq 1, product []
454
+
455
+ test 'list as input' ->
456
+ eq 24, product [1 2 3 4]
457
+
458
+ test 'negative numbers' ->
459
+ eq -6, product [1 -2 3]
460
+
461
+ suite 'mean' ->
462
+ test 'empty list as input' ->
463
+ ok is-it-NaN mean []
464
+
465
+ test 'list as input' ->
466
+ eq 4, mean [2 3 4 5 6]
467
+
468
+ test 'average as alias' ->
469
+ eq mean, average
470
+
471
+ suite 'maximum' ->
472
+ test 'empty list as input' ->
473
+ eq void, maximum []
474
+
475
+ test 'single element list' ->
476
+ eq 1, maximum [1]
477
+
478
+ test 'multi element list' ->
479
+ eq 6, maximum [1 2 6 4 5]
480
+
481
+ suite 'minimum' ->
482
+ test 'empty list as input' ->
483
+ eq void, minimum []
484
+
485
+ test 'single element list' ->
486
+ eq 1, minimum [1]
487
+
488
+ test 'multi element list' ->
489
+ eq 2, minimum [4 3 2 6 9]
490
+
491
+ test 'list of strings' ->
492
+ eq 'a', minimum ['c', 'e', 'a', 'd', 'b']
493
+
494
+ suite 'scan' ->
495
+ test 'empty list as input' ->
496
+ deep-eq [null], scan id, null, []
497
+
498
+ test 'complex case' ->
499
+ deep-eq [4,9,20,43], scan ((x, y) -> 2 * x + y), 4, [1 2 3]
500
+
501
+ test 'scanl as alias' ->
502
+ eq scan, scanl
503
+
504
+ test 'curried' ->
505
+ f = scan ((x, y) -> 2 * x + y)
506
+ deep-eq [4,9,20,43], f 4, [1 2 3]
507
+
508
+ g = scan ((x, y) -> 2 * x + y), 4
509
+ deep-eq [4,9,20,43], g [1 2 3]
510
+
511
+ suite 'scan1' ->
512
+ test 'empty list as input' ->
513
+ deep-eq void, scan1 id, []
514
+
515
+ test 'complex case' ->
516
+ deep-eq [1,3,6,10], scan1 (+), [1 2 3 4]
517
+
518
+ test 'scanl1 as alias' ->
519
+ eq scan1, scanl1
520
+
521
+ test 'curried' ->
522
+ f = scan1 (+)
523
+ deep-eq [1,3,6,10], f [1 2 3 4]
524
+
525
+ suite 'scanr' ->
526
+ test 'empty list as input' ->
527
+ deep-eq [null], scanr id, null, []
528
+
529
+ test 'complex case' ->
530
+ deep-eq [15,14,12,9,5], scanr (+), 5, [1 2 3 4]
531
+
532
+ test 'curried' ->
533
+ f = scanr (+)
534
+ deep-eq [15,14,12,9,5], f 5, [1 2 3 4]
535
+
536
+ g = scanr (+), 5
537
+ deep-eq [15,14,12,9,5], g [1 2 3 4]
538
+
539
+ suite 'scanr1' ->
540
+ test 'empty list as input' ->
541
+ deep-eq void, scanr1 id, []
542
+
543
+ test 'complex case' ->
544
+ deep-eq [10,9,7,4], scanr1 (+), [1 2 3 4]
545
+
546
+ test 'curried' ->
547
+ f = scanr1 (+)
548
+ deep-eq [10,9,7,4], f [1 2 3 4]
549
+
550
+ suite 'slice' ->
551
+ test 'zero to zero' ->
552
+ deep-eq [], slice 0 0 [1 2 3 4 5]
553
+
554
+ test 'empty lsit as input' ->
555
+ deep-eq [], slice 2 3 []
556
+
557
+ test 'parts' ->
558
+ deep-eq [3 4], slice 2 4 [1 2 3 4 5]
559
+
560
+ test 'curried' ->
561
+ f = slice 2
562
+ deep-eq [3 4], f 4 [1 2 3 4 5]
563
+
564
+ g = slice 2 4
565
+ deep-eq [3 4], g [1 2 3 4 5]
566
+
567
+ suite 'take' ->
568
+ test 'empty list as input' ->
569
+ deep-eq [], take 3 []
570
+
571
+ test 'zero on list' ->
572
+ deep-eq [], take 0 [1 2 3 4 5]
573
+
574
+ test 'negative number' ->
575
+ deep-eq [], take -1 [1 2 3 4 5]
576
+
577
+ test 'too big number' ->
578
+ deep-eq [1 2 3 4 5], take 9 [1 2 3 4 5]
579
+
580
+ test 'list' ->
581
+ deep-eq [1 2 3], take 3 [1 2 3 4 5]
582
+
583
+ test 'curried' ->
584
+ f = take 3
585
+ deep-eq [1 2 3], f [1 2 3 4 5]
586
+
587
+ suite 'drop' ->
588
+ test 'empty list as input' ->
589
+ deep-eq [], drop 3 []
590
+
591
+ test 'zero on list' ->
592
+ deep-eq [1 2 3 4 5], drop 0 [1 2 3 4 5]
593
+
594
+ test 'negative number' ->
595
+ deep-eq [1 2 3 4 5], drop -1 [1 2 3 4 5]
596
+
597
+ test 'too big number' ->
598
+ deep-eq [], drop 9 [1 2 3 4 5]
599
+
600
+ test 'list' ->
601
+ deep-eq [4 5], drop 3 [1 2 3 4 5]
602
+
603
+ test 'curried' ->
604
+ f = drop 3
605
+ deep-eq [4 5], f [1 2 3 4 5]
606
+
607
+ suite 'split-at' ->
608
+ test 'empty list as input' ->
609
+ deep-eq [[], []], split-at 3 []
610
+
611
+ test 'zero on list' ->
612
+ deep-eq [[], [1 2 3 4 5]], split-at 0 [1 2 3 4 5]
613
+
614
+ test 'negative number' ->
615
+ deep-eq [[], [1 2 3 4 5]], split-at -1 [1 2 3 4 5]
616
+
617
+ test 'too big number' ->
618
+ deep-eq [[1 2 3 4 5], []], split-at 9 [1 2 3 4 5]
619
+
620
+ test 'list' ->
621
+ deep-eq [[1 2 3], [4 5]], split-at 3 [1 2 3 4 5]
622
+
623
+ test 'curried' ->
624
+ f = split-at 3
625
+ deep-eq [[1 2 3], [4 5]], f [1 2 3 4 5]
626
+
627
+ suite 'take-while' ->
628
+ test 'empty list as input' ->
629
+ deep-eq [], take-while id, []
630
+
631
+ test 'list' ->
632
+ deep-eq [1 3 5], take-while odd, [1 3 5 4 8 7 9]
633
+
634
+ test 'all pass' ->
635
+ deep-eq [42], take-while (== 42), [42]
636
+ deep-eq [2 4 8], take-while even, [2 4 8]
637
+
638
+ test 'all fail' ->
639
+ deep-eq [], take-while (== 7), [42]
640
+ deep-eq [], take-while odd, [2 4 8]
641
+
642
+ test 'curried' ->
643
+ f = take-while odd
644
+ deep-eq [1 3 5], f [1 3 5 4 8 7 9]
645
+
646
+ suite 'drop-while' ->
647
+ test 'empty list as input' ->
648
+ deep-eq [], drop-while id, []
649
+
650
+ test 'list' ->
651
+ deep-eq [7 9 10], drop-while even, [2 4 6 7 9 10]
652
+
653
+ test 'all pass' ->
654
+ deep-eq [], drop-while (== 42), [42]
655
+ deep-eq [], drop-while even, [2 4 8]
656
+
657
+ test 'all-fail' ->
658
+ deep-eq [42], drop-while (== 7), [42]
659
+ deep-eq [2 4 8], drop-while odd, [2 4 8]
660
+
661
+ test 'curried' ->
662
+ f = drop-while even
663
+ deep-eq [7 9 10], f [2 4 6 7 9 10]
664
+
665
+ suite 'span' ->
666
+ test 'empty list as input' ->
667
+ deep-eq [[], []], span id, []
668
+
669
+ test 'list' ->
670
+ deep-eq [[2 4 6], [7 9 10]], span even, [2 4 6 7 9 10]
671
+
672
+ test 'curried' ->
673
+ f = span even
674
+ deep-eq [[2 4 6], [7 9 10]], f [2 4 6 7 9 10]
675
+
676
+ suite 'break-list' ->
677
+ test 'empty list as input' ->
678
+ deep-eq [[], []], break-list id, []
679
+
680
+ test 'list' ->
681
+ deep-eq [[1 2], [3 4 5]], break-list (== 3), [1 2 3 4 5]
682
+
683
+ test 'curried' ->
684
+ f = break-list (== 3)
685
+ deep-eq [[1 2], [3 4 5]], f [1 2 3 4 5]
686
+
687
+ suite 'zip' ->
688
+ test 'empty lists as input' ->
689
+ deep-eq [], zip [] []
690
+
691
+ test 'equal length lists' ->
692
+ deep-eq [[1 4], [2 5]], zip [1 2] [4 5]
693
+
694
+ test 'first list shorter' ->
695
+ deep-eq [[1 4], [2 5]], zip [1 2] [4 5 6]
696
+
697
+ test 'second list shorter' ->
698
+ deep-eq [[1 4], [2 5]], zip [1 2 3] [4 5]
699
+
700
+ test 'curried' ->
701
+ f = zip [1 2]
702
+ deep-eq [[1 4], [2 5]], f [4 5]
703
+
704
+ suite 'zip-with' ->
705
+ test 'empty lists as input' ->
706
+ deep-eq [], zip-with id, [], []
707
+
708
+ test 'equal length lists' ->
709
+ deep-eq [4 4 4], zip-with (+), [1 2 3], [3 2 1]
710
+
711
+ test 'first list shorter' ->
712
+ deep-eq [5 7], zip-with (+), [1 2], [4 5 6]
713
+
714
+ test 'second list shorter' ->
715
+ deep-eq [5 7], zip-with (+), [1 2 3] [4 5]
716
+
717
+ test 'curried' ->
718
+ f = zip-with (+)
719
+ deep-eq [4 4 4], f [1 2 3], [3 2 1]
720
+
721
+ g = zip-with (+), [1 2 3]
722
+ deep-eq [4 4 4], g [3 2 1]
723
+
724
+ suite 'zip-all' ->
725
+ test 'empty lists as input' ->
726
+ deep-eq [], zip-all [] [] []
727
+
728
+ test 'equal length lists' ->
729
+ deep-eq [[1 4 7], [2 5 8], [3 6 9]], zip-all [1 2 3] [4 5 6] [7 8 9]
730
+
731
+ test 'first list shorter' ->
732
+ deep-eq [[1 4 7], [2 5 8]], zip-all [1 2] [4 5 6] [7 8 9]
733
+
734
+ test 'second list shorter' ->
735
+ deep-eq [[1 4 7], [2 5 8]], zip-all [1 2 3] [4 5] [7 8 9]
736
+
737
+ test 'third list shorter' ->
738
+ deep-eq [[1 4 7], [2 5 8]], zip-all [1 2 3] [4 5 6] [7 8]
739
+
740
+ suite 'zip-all-with' ->
741
+ test 'empty lists as input' ->
742
+ deep-eq [], zip-all-with id, [], []
743
+
744
+ test 'equal length lists' ->
745
+ deep-eq [5 5 5], zip-all-with (-> &0 + &1 + &2), [1 2 3], [3 2 1], [1 1 1]
746
+
747
+ test 'first list shorter' ->
748
+ deep-eq [5 7], zip-all-with (+), [1 2], [4 5 6]
749
+
750
+ test 'second list shorter' ->
751
+ deep-eq [5 7], zip-all-with (+), [1 2 3] [4 5]