From 803b973c4210aa55885460d4454f95a6a3469912 Mon Sep 17 00:00:00 2001
From: Brady James Garvin <bgarvin@cse.unl.edu>
Date: Thu, 14 Nov 2019 17:51:50 -0600
Subject: [PATCH] Updated lab for 2019.

---
 .eslintrc                             |  3 +++
 js/binary_search_tree.js              | 15 +++++++++++----
 unit_tests/test_enumeration.js        |  6 ++++--
 unit_tests/test_insertion.js          |  6 ++++--
 unit_tests/test_membership.js         |  6 ++++--
 unit_tests/test_multiple_insertion.js |  6 ++++--
 unit_tests/test_multiple_removal.js   |  6 ++++--
 unit_tests/test_removal.js            |  6 ++++--
 unit_tests/unit_tests.html            | 13 ++++++-------
 9 files changed, 44 insertions(+), 23 deletions(-)

diff --git a/.eslintrc b/.eslintrc
index ec0d68b..15eefba 100755
--- a/.eslintrc
+++ b/.eslintrc
@@ -4,6 +4,9 @@
     "browser": true,
     "jquery": true,
   },
+  "parserOptions": {
+    "sourceType": "module",
+  },
   "rules": {
     "no-await-in-loop": "warn",
     "no-compare-neg-zero": "warn",
diff --git a/js/binary_search_tree.js b/js/binary_search_tree.js
index f343d46..74188ab 100644
--- a/js/binary_search_tree.js
+++ b/js/binary_search_tree.js
@@ -1,5 +1,3 @@
-/* exported BinarySearchTree */
-
 function opposite(side) {
   return 1 - side;
 }
@@ -79,7 +77,7 @@ class BSTNode {
   }
 }
 
-class BinarySearchTree {
+export class BinarySearchTree {
   constructor(elements = []) {
     this.root = undefined;
     for (const element of elements) {
@@ -122,7 +120,16 @@ class BinarySearchTree {
   }
 
   delete(element) {
-    // TODO: stub
+    let moribund = this._find(element);
+    if (moribund.isBranch()) {
+      const original = moribund;
+      // TODO: incomplete
+      original.swap(moribund);
+    }
+    // TODO: incomplete
+    if (this.root === moribund) {
+      // TODO: incomplete
+    }
   }
 
   enumerate(inclusiveMinimum, exclusiveMaximum) {
diff --git a/unit_tests/test_enumeration.js b/unit_tests/test_enumeration.js
index fbee1a3..26c37d1 100644
--- a/unit_tests/test_enumeration.js
+++ b/unit_tests/test_enumeration.js
@@ -1,5 +1,7 @@
-QUnit.module('enumeration');
-/* globals QUnit BinarySearchTree */
+import {BinarySearchTree} from '../js/binary_search_tree.js';
+
+/* globals QUnit */
+QUnit.module('test_enumeration.js');
 /* eslint-disable no-magic-numbers */
 
 QUnit.test('Enumeration test #0', (assert) => {
diff --git a/unit_tests/test_insertion.js b/unit_tests/test_insertion.js
index 0067754..9559932 100644
--- a/unit_tests/test_insertion.js
+++ b/unit_tests/test_insertion.js
@@ -1,5 +1,7 @@
-QUnit.module('insertion');
-/* globals QUnit BinarySearchTree */
+import {BinarySearchTree} from '../js/binary_search_tree.js';
+
+/* globals QUnit */
+QUnit.module('test_insertion.js');
 /* eslint-disable no-magic-numbers */
 
 QUnit.test('Insertion test #0', (assert) => {
diff --git a/unit_tests/test_membership.js b/unit_tests/test_membership.js
index e045322..9a97d9a 100644
--- a/unit_tests/test_membership.js
+++ b/unit_tests/test_membership.js
@@ -1,5 +1,7 @@
-QUnit.module('membership');
-/* globals QUnit BinarySearchTree */
+import {BinarySearchTree} from '../js/binary_search_tree.js';
+
+/* globals QUnit */
+QUnit.module('test_membership.js');
 /* eslint-disable no-magic-numbers */
 
 QUnit.test('Membership test #0', (assert) => {
diff --git a/unit_tests/test_multiple_insertion.js b/unit_tests/test_multiple_insertion.js
index a581cd9..ac3ff83 100644
--- a/unit_tests/test_multiple_insertion.js
+++ b/unit_tests/test_multiple_insertion.js
@@ -1,5 +1,7 @@
-QUnit.module('multiple insertion');
-/* globals QUnit BinarySearchTree */
+import {BinarySearchTree} from '../js/binary_search_tree.js';
+
+/* globals QUnit */
+QUnit.module('test_multiple_insertion.js');
 /* eslint-disable no-magic-numbers */
 
 QUnit.test('Mulitple insertion test #0', (assert) => {
diff --git a/unit_tests/test_multiple_removal.js b/unit_tests/test_multiple_removal.js
index 7ca0aca..7a31483 100644
--- a/unit_tests/test_multiple_removal.js
+++ b/unit_tests/test_multiple_removal.js
@@ -1,5 +1,7 @@
-QUnit.module('multiple removal');
-/* globals QUnit BinarySearchTree */
+import {BinarySearchTree} from '../js/binary_search_tree.js';
+
+/* globals QUnit */
+QUnit.module('test_multiple_removal.js');
 /* eslint-disable no-magic-numbers */
 
 QUnit.test('Multiple removal test #0', (assert) => {
diff --git a/unit_tests/test_removal.js b/unit_tests/test_removal.js
index 1648a6e..088f710 100644
--- a/unit_tests/test_removal.js
+++ b/unit_tests/test_removal.js
@@ -1,5 +1,7 @@
-QUnit.module('removal');
-/* globals QUnit BinarySearchTree */
+import {BinarySearchTree} from '../js/binary_search_tree.js';
+
+/* globals QUnit */
+QUnit.module('test_removal.js');
 /* eslint-disable no-magic-numbers */
 
 QUnit.test('Removal test #0', (assert) => {
diff --git a/unit_tests/unit_tests.html b/unit_tests/unit_tests.html
index 89b9bcb..056d981 100644
--- a/unit_tests/unit_tests.html
+++ b/unit_tests/unit_tests.html
@@ -13,13 +13,12 @@
   <script src="../libraries/qunit/qunit.js"></script>
   <script src="overrides.js"></script>
 
-  <script src="../js/binary_search_tree.js"></script>
-  <script src="test_insertion.js"></script>
-  <script src="test_membership.js"></script>
-  <script src="test_multiple_insertion.js"></script>
-  <script src="test_removal.js"></script>
-  <script src="test_multiple_removal.js"></script>
-  <script src="test_enumeration.js"></script>
+  <script type="module" src="test_insertion.js"></script>
+  <script type="module" src="test_membership.js"></script>
+  <script type="module" src="test_multiple_insertion.js"></script>
+  <script type="module" src="test_removal.js"></script>
+  <script type="module" src="test_multiple_removal.js"></script>
+  <script type="module" src="test_enumeration.js"></script>
 </body>
 
 </html>
-- 
GitLab