Skip to content

Commit 622fed8

Browse files
committed
WIP: add sortedmap.test.ts
1 parent a046261 commit 622fed8

File tree

4 files changed

+411
-9
lines changed

4 files changed

+411
-9
lines changed

src/database/core/util/SortedMap.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -714,35 +714,35 @@ export class SortedMap {
714714
* @param {(function(K, V):T)=} opt_resultGenerator
715715
* @return {SortedMapIterator.<K, V, T>} The iterator.
716716
*/
717-
getIterator(opt_resultGenerator) {
717+
getIterator(resultGnerator?) {
718718
return new SortedMapIterator(this.root_,
719719
null,
720720
this.comparator_,
721721
false,
722-
opt_resultGenerator);
722+
resultGnerator);
723723
}
724724

725-
getIteratorFrom(key, opt_resultGenerator) {
725+
getIteratorFrom(key, resultGnerator?) {
726726
return new SortedMapIterator(this.root_,
727727
key,
728728
this.comparator_,
729729
false,
730-
opt_resultGenerator);
730+
resultGnerator);
731731
}
732732

733-
getReverseIteratorFrom(key, opt_resultGenerator) {
733+
getReverseIteratorFrom(key, resultGnerator?) {
734734
return new SortedMapIterator(this.root_,
735735
key,
736736
this.comparator_,
737737
true,
738-
opt_resultGenerator);
738+
resultGnerator);
739739
}
740740

741-
getReverseIterator(opt_resultGenerator) {
741+
getReverseIterator(resultGnerator?) {
742742
return new SortedMapIterator(this.root_,
743743
null,
744744
this.comparator_,
745745
true,
746-
opt_resultGenerator);
746+
resultGnerator);
747747
}
748748
}; // end SortedMap

tests/database/helpers.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,14 @@ export function pause(milliseconds: number) {
103103

104104
export function getPath(query: Query) {
105105
return query.toString().replace(TEST_PROJECT.databaseURL, '');
106+
}
107+
108+
export function shuffle(arr, randFn?) {
109+
var randFn = randFn || Math.random;
110+
for (var i = arr.length - 1;i > 0;i--) {
111+
var j = Math.floor(randFn() * (i + 1));
112+
var tmp = arr[i];
113+
arr[i] = arr[j];
114+
arr[j] = tmp;
115+
}
106116
}

tests/database/node.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ChildrenNode } from "../../src/database/core/snap/ChildrenNode";
88
import { NAME_COMPARATOR } from "../../src/database/core/snap/comparators";
99
import { nodeFromJSON } from "../../src/database/core/snap/nodeFromJSON";
1010

11-
describe.only('Node Tests', function() {
11+
describe('Node Tests', function() {
1212
var DEFAULT_INDEX = PRIORITY_INDEX;
1313

1414
it('Create leaf nodes of various types.', function() {

0 commit comments

Comments
 (0)