-
Notifications
You must be signed in to change notification settings - Fork 0
/
arb-tests.js
66 lines (63 loc) · 1.74 KB
/
arb-tests.js
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
module.exports = test
var arb = require('../arb')
var strings = require('./food.js')
function nodups(arr, next){
if ( arr.indexOf(next) == -1 ) arr.push(next)
return arr
}
function test(){
var results = []
var numbers = []
for ( var i = 0; i < strings.length; i++ ) {
var x = arb.parse(strings[i])
numbers.push(x)
}
function inputs(n){
return numbers.indexOf(n) == -1
}
return {
clean: function clear(){
results = results.reduce(nodups, []).filter(inputs)
for ( var i = 0; i < results.length; i++ ) {
arb.memory.free(results[i])
}
results = []
}
, cleanDiv: function clear(){
results = results.reduce(nodups, []).filter(inputs)
for ( var i = 0; i < results.length; i++ ) {
arb.memory.free(results[i][0])
arb.memory.free(results[i][1])
}
results = []
}
, addition: function addition(){
for ( var i = 0; i < numbers.length; i++ ) {
for ( var j = 0; j < numbers.length; j++ ) {
results.push(arb.add(numbers[i], numbers[j]))
}
}
}
, subtraction: function addition(){
for ( var i = 0; i < numbers.length; i++ ) {
for ( var j = 0; j < numbers.length; j++ ) {
results.push(arb.subtract(numbers[i], numbers[j]))
}
}
}
, multiplication: function multiplication(){
for ( var i = 0; i < numbers.length; i++ ) {
for ( var j = 0; j < numbers.length; j++ ) {
results.push(arb.multiply(numbers[i], numbers[j]))
}
}
}
, division: function division(){
for ( var i = 0; i < numbers.length; i++ ) {
for ( var j = 0; j < numbers.length; j++ ) {
results.push(arb.divide(numbers[i], numbers[j]))
}
}
}
}
}