Skip to content

Commit

Permalink
Merge branch 'master' into merge-1
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-kulcsar authored Nov 10, 2024
2 parents 1aa2b95 + 77b06c2 commit 60d8190
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
33 changes: 33 additions & 0 deletions get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace GetTests {
export function run(): boolean {
let allPassed: boolean = true
let test: TernaryStringSet = new TernaryStringSet()

// Get() on an empty set will be null.
if (test.get(0) !== null) {
game.splash("Get test 1 failed.")
allPassed = false
}

test.add("")
if (test.get(0) !== "") {
game.splash("Get test 2 failed.")
allPassed = false
}

test.clear()
test.addAll(ShortEnglishList.words)
console.log("Get random words from short word list.")
for (let count: number = 0; count < 100; count++) {
let index: number = randint(0, test.size - 1)
let word: string = test.get(index)
console.log(word)
if (word.length == 0) {
game.splash(`Get test 3 count ${count} failed; index = ${index}.`)
allPassed = false
}
}

return allPassed
}
}
1 change: 1 addition & 0 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let tests: (() => boolean)[] = [
Balance.run,
Compact.run,
Serialization.run,
GetTests.run,
]

for (let t of tests) {
Expand Down
3 changes: 2 additions & 1 deletion pxt.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"compact.ts",
"common.ts",
"serialization.ts",
"serialized-short-list.ts"
"serialized-short-list.ts",
"get.ts"
],
"testDependencies": {},
"targetVersions": {
Expand Down

0 comments on commit 60d8190

Please sign in to comment.