From 5cc071b82b8916a9c6fc213599a3714612b5cfcb Mon Sep 17 00:00:00 2001 From: Holden Rohrer Date: Thu, 16 Jul 2020 12:40:56 -0400 Subject: improved space correctness Subsections have valid locs, and built-in assumptions are asserted like a valid loc in a towrite() or the structure of a subsection() call --- space.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/space.js b/space.js index 1828dda..65b5355 100644 --- a/space.js +++ b/space.js @@ -53,6 +53,7 @@ function Space(){ } this.towrite = function(){ // Does no splitting or anything like that. Just returns a list of triplets for the write function + if (this.loc[0] === undefined) throw "Space.towrite() requires valid loc"; let writes = []; for (let line = 0; line < this.data.length; line++) for (let chr = 0; chr < this.data[line].length; chr++){ if (this.data[line][chr] == '') continue; // Internal coding for "do not write" @@ -138,6 +139,7 @@ function Space(){ } this.subsection = function(range){ // range is a coordinate pair + if (range.length !== 2 || range[0].length !== 2) throw "not subsecting a coord pair"; // Similarly excludes this.loc newspace = new Space(); for (let line=range[0][0]; line