diff options
author | sanine <sanine.not@pm.me> | 2023-06-10 02:18:49 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-06-10 02:18:49 -0500 |
commit | 20bfb89690618936b61ae79fbc8a6f0071b25060 (patch) | |
tree | cfd0a1805060bdb82dc96e6995b948c6cee175f3 /src | |
parent | e9e44dcfda8828eb6fa9d40eabd908d3fb81151d (diff) |
begin writing mind topology
Diffstat (limited to 'src')
-rw-r--r-- | src/mind/topology.js | 14 | ||||
-rw-r--r-- | src/mind/topology.test.js | 31 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/mind/topology.js b/src/mind/topology.js new file mode 100644 index 0000000..58e229e --- /dev/null +++ b/src/mind/topology.js @@ -0,0 +1,14 @@ +'use strict'; + + +const PointProto = { + +}; + + +export function Point(layer, index) { + return Object.freeze({ + layer, + index, + }); +} diff --git a/src/mind/topology.test.js b/src/mind/topology.test.js new file mode 100644 index 0000000..421eb17 --- /dev/null +++ b/src/mind/topology.test.js @@ -0,0 +1,31 @@ +'use strict'; + +import { Point } from './topology'; + +test('Point works correctly', () => { + const p = Point(0, 1); + expect(p.layer).toBe(0); + expect(p.index).toBe(1); + expect(() => p.layer = 5).toThrow(); +}); + + +test('Point equality works correctly', () => { + const a00 = Point(0, 0); + const b00 = Point(0, 0); + const a01 = Point(0, 1); + const b01 = Point(0, 1); + const a10 = Point(1, 0); + const b10 = Point(1, 0); + const a11 = Point(1, 1); + const b11 = Point(1, 1); + + expect(a00 == b00).toBeTruthy(); + expect(a01 == b01).toBeTruthy(); + expect(a10 == b10).toBeTruthy(); + expect(a11 == b11).toBeTruthy(); + + expect(a00 == a01).toBeFalsy(); + expect(a00 == a10).toBeFalsy(); + expect(a00 == a11).toBeFalsy(); +}); |