summaryrefslogtreecommitdiff
path: root/src/genome/genome.test.js
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-08-10 15:27:32 -0500
committersanine-a <sanine.not@pm.me>2023-08-10 15:27:32 -0500
commit49312fea07e56e2d74179f4160a16cac6f614f97 (patch)
treed46e6c0f88d40b38969c8e844063545b7b7ccd7e /src/genome/genome.test.js
parent0460985d38d137fd02db4919c66d316a83d2919e (diff)
add is_valid()
Diffstat (limited to 'src/genome/genome.test.js')
-rw-r--r--src/genome/genome.test.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/genome/genome.test.js b/src/genome/genome.test.js
index ca56092..f50531b 100644
--- a/src/genome/genome.test.js
+++ b/src/genome/genome.test.js
@@ -1,6 +1,9 @@
'use strict';
-import { mutation_type, mutate } from './genome';
+import {
+ mutation_type, mutate,
+ is_valid,
+} from './genome';
test('basic gene mutations', () => {
@@ -18,3 +21,11 @@ test('basic gene mutations', () => {
expect(mutate([0, 1, 2], mutation_type.weight, 0.0)).toEqual([0, 1, -1]);
expect(mutate([0, 1, 2], mutation_type.weight, 1.0)).toEqual([0, 1, 3]);
});
+
+
+test('genome validation', () => {
+ expect(is_valid(0, 0, [ [ 0, 0, 1.0 ] ])).toBe(true);
+ expect(is_valid(2, 1, [ [ 0, 2, 1 ] ])).toBe(true);
+ expect(is_valid(2, 1, [ [ 0, 1, 1 ] ])).toBe(false);
+ expect(is_valid(2, 1, [ [ 0, 2, 5 ] ])).toBe(false);
+});