Update tests. remove converted test for the time being

This commit is contained in:
Sam El-Husseini 2018-04-21 10:45:02 -07:00
parent ff892dbcb4
commit 6ac64f0e3d
11 changed files with 36 additions and 32 deletions

View File

@ -8,7 +8,7 @@ script:
- "(cd libs/lang-test0; node ../../node_modules/pxt-core/built/pxt.js test)"
- "(cd libs/lang-test1; node ../../node_modules/pxt-core/built/pxt.js test)"
- "node node_modules/pxt-core/built/pxt.js testdir tests"
- "(cd libs/hello; node ../../node_modules/pxt-core/built/pxt.js testconv http://az851932.vo.msecnd.net/files/td-converter-tests-v1.json)"
# - "(cd libs/hello; node ../../node_modules/pxt-core/built/pxt.js testconv http://az851932.vo.msecnd.net/files/td-converter-tests-v1.json)"
sudo: false
notifications:
email:

View File

@ -14,4 +14,8 @@ namespace Math {
export function randomBoolean(): boolean {
return Math.random() >= 0.5;
}
export function randomInt(max: number): number {
return Math.floor(Math.random() * max);
}
}

View File

@ -197,7 +197,7 @@ function playLevel(level1: number) {
led.plot(2 * i, 2)
}
basic.pause(1000)
correctBall = Math.random(3)
correctBall = Math.randomInt(3)
revealBall(correctBall)
basic.pause(1000)
let swaps = 5 + 10 * level1
@ -209,17 +209,17 @@ function playLevel(level1: number) {
swapSpeed = 20
}
for (let i1 = 0; i1 < swaps; i1++) {
let swapType = Math.random(3)
let not = Math.random(3)
let swapType = Math.randomInt(3)
let not = Math.randomInt(3)
if (swapType < 2) {
let swapOrientation = Math.random(2)
let swapOrientation = Math.randomInt(2)
if (swapOrientation == 0) {
swapCups((not + 1) % 3, (not + 2) % 3, swapSpeed)
} else {
swapCups((not + 2) % 3, (not + 1) % 3, swapSpeed)
}
} else {
let swapOrientation1 = Math.random(2)
let swapOrientation1 = Math.randomInt(2)
if (swapOrientation1 == 0) {
swapFake((not + 1) % 3, (not + 2) % 3, swapSpeed)
} else {

View File

@ -38,9 +38,9 @@ input.onButtonPressed(Button.B, () => {
led.plot(twoX, twoY)
}
})
meteoriteOneX = Math.random(5)
meteoriteOneX = Math.randomInt(5)
meteoriteOneY = 0
meteoriteTwoX = Math.random(5)
meteoriteTwoX = Math.randomInt(5)
meteoriteTwoY = -3
basic.pause(1000)
for (let i = 0; i < 3; i++) {
@ -84,7 +84,7 @@ basic.forever(() => {
}
}
while (Math.abs(meteoriteTwoX - meteoriteOneX) < 1) {
meteoriteOneX = Math.random(5)
meteoriteOneX = Math.randomInt(5)
}
meteoriteOneY = 0
counter = counter + 1
@ -133,9 +133,9 @@ basic.forever(() => {
}
}
meteoriteTwoX = Math.random(5)
meteoriteTwoX = Math.randomInt(5)
while (Math.abs(meteoriteTwoX - meteoriteOneX) < 1) {
meteoriteTwoX = Math.random(5)
meteoriteTwoX = Math.randomInt(5)
}
meteoriteTwoY = 0
counter = counter + 1

View File

@ -25,7 +25,7 @@ class Entity {
} else if (this.x == 4) {
return - 1
} else {
return Math.random(2) * 2 - 1
return Math.randomInt(2) * 2 - 1
}
}
@ -35,7 +35,7 @@ class Entity {
} else if (this.y == 4) {
return - 1
} else {
return Math.random(2) * 2 - 1
return Math.randomInt(2) * 2 - 1
}
}
@ -162,7 +162,7 @@ function logic() {
m.dirX = m.towardsX(person)
m.dirY = m.towardsY(person)
if (m.dirX != 0 && m.dirY != 0) {
let x = Math.random(2)
let x = Math.randomInt(2)
if (x == 1) {
m.dirX = 0
} else {
@ -224,7 +224,7 @@ function resetState() {
for (let i = 0; i < totalMonsters; i++) {
let busy = busyPos[i]
let m = monsters[i]
m.x = (busy.x + Math.random(3)) - 1
m.y = (busy.y + Math.random(3)) - 1
m.x = (busy.x + Math.randomInt(3)) - 1
m.y = (busy.y + Math.randomInt(3)) - 1
}
}

View File

@ -64,7 +64,7 @@ function playGame(): number {
while (true) {
if (state == "NEWDROP") {
// create a new drop at a random position
dropX = Math.random(5)
dropX = Math.randomInt(5)
dropY = 0
state = "RAINING"
} else if (state == "RAINING") {

View File

@ -127,7 +127,7 @@ function playCybermen(): number {
} else {
cybermanLineupCount = 0
// Move Cyberman closer to player, slowly
if (Math.random(100) < cybermanMoveXProbability) {
if (Math.randomInt(100) < cybermanMoveXProbability) {
if (cybermanX > playerX) {
cybermanX = cybermanX - 1
} else if (cybermanX < playerX) {
@ -170,7 +170,7 @@ function playDalek(): number {
if (tilt > 2) {
// Moving up, slowly
if (userY < 4) {
if (Math.random(100) < userMoveSensitivity) {
if (Math.randomInt(100) < userMoveSensitivity) {
userY = userY + 1
redraw = true
}
@ -178,7 +178,7 @@ function playDalek(): number {
} else if (tilt < 2) {
// Moving down (slowly)
if (userY > 0) {
if (Math.random(100) < userMoveSensitivity) {
if (Math.randomInt(100) < userMoveSensitivity) {
userY = userY - 1
redraw = true
}
@ -186,24 +186,24 @@ function playDalek(): number {
}
// Move the Dalek to line up with user
if (dalekY < userY) {
if (Math.random(100) < dalekMoveSensitivity) {
if (Math.randomInt(100) < dalekMoveSensitivity) {
dalekY = dalekY + 1
redraw = true
}
} else if (dalekY > userY) {
if (Math.random(100) < dalekMoveSensitivity) {
if (Math.randomInt(100) < dalekMoveSensitivity) {
dalekY = dalekY - 1
redraw = true
}
} else {
// Dalek lines up
if (Math.random(100) < dalekShootChance) {
if (Math.randomInt(100) < dalekShootChance) {
// Shoot a raygun at the user
for (let i = 0; i < 3; i++) {
led.plot(i + 1, dalekY)
basic.pause(100)
}
if (Math.random(100) < dalekHitChance) {
if (Math.randomInt(100) < dalekHitChance) {
// User has been hit, game over
break
}
@ -332,7 +332,7 @@ function playJudoonLanguage(): number {
. # # # . # # # . . # . # . # # # # # # # . . . #
`)
let pages = "029 041 167 208 283"
let actualAnswer = Math.random(5)
let actualAnswer = Math.randomInt(5)
let pos = 0
let redraw = true
while (gameTime < maxGameTime) {

View File

@ -156,7 +156,7 @@ function surgery(): number {
`, 150)
state = "SHOCKED"
} else if (state == "SHOCKED") {
let recover = Math.random(100)
let recover = Math.randomInt(100)
if (recover >= recoveryProbability) {
state = "RECOVERED"
} else {

View File

@ -75,8 +75,8 @@ function alertnessTest() {
// Run 10 random cognition response tests
for (let i = 0; i < 9; i++) {
// Choose random delay and random outcome
let delay = Math.random(5) + 5
let outcome = Math.random(2)
let delay = Math.randomInt(5) + 5
let outcome = Math.randomInt(2)
// Draw moving dots on screen until delay expires
basic.clearScreen()
for (let j = 0; j < delay; j++) {

View File

@ -54,7 +54,7 @@ function playOneGame(): number {
. . . . . . # # # . . . # . . . . # . . . . # . . . . # . . . . # . . . # # # . . . . . . . . . . .
. # # # . . . # . . . . # . . . . # . . . . # . . . . # . . . . # . . . . # . . . # # # . . . . . .
`, 50)
let pos = Math.random(5)
let pos = Math.randomInt(5)
if (xdir) {
if (!canvas.pixel(pos, y)) {
canvas.setPixel(pos, y, true)
@ -70,9 +70,9 @@ function playOneGame(): number {
xdir = !xdir
bearing = input.compassHeading()
if (xdir) {
x = Math.random(5)
x = Math.randomInt(5)
} else {
y = Math.random(5)
y = Math.randomInt(5)
}
} else {
basic.pause(100)

View File

@ -54,7 +54,7 @@ function runGameOnce() {
}
// Run code appropriate to the present state of the game
if (state == "NEWSIDE") {
target_time = 5 + Math.random(5)
target_time = 5 + Math.randomInt(5)
state = "COOKING"
startTimer()
} else if (state == "COOKING") {