From b863d5663dfb6c802de2124322aaa63e7843e0c1 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Thu, 18 Aug 2016 10:52:19 +0300 Subject: [PATCH 1/6] Add buffer shift rotate tests (moved from pxt) --- libs/lang-test1/lang-test1.ts | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/libs/lang-test1/lang-test1.ts b/libs/lang-test1/lang-test1.ts index 0b917344..89339e4b 100644 --- a/libs/lang-test1/lang-test1.ts +++ b/libs/lang-test1/lang-test1.ts @@ -22,6 +22,7 @@ console.log("Starting...") basic.showNumber(0); testBuffer() +testBufferShiftRotate() basic.showNumber(2); console.log("ALL TESTS OK") @@ -75,3 +76,63 @@ function testBuffer() { b.shift(-1) bufferIs(b, [0, 4, 13]); } + + +function testBufferShiftRotate() { + let b = pins.createBuffer(5); + + function initb() { + for (let i = 0; i < b.length; ++i) { + b[i] = i; + } + } + function assertb(ex: number[]) { + bufferIs(b, ex) + } + + initb() + assertb([0, 1, 2, 3, 4]) + + //shifting + initb() + b.shift(-1); + assertb([0, 0, 1, 2, 3]) + + initb() + b.shift(-1, 0, 3); + assertb([0, 0, 1, 3, 4]) + + initb() + b.shift(-1, 1, 3); + assertb([0, 0, 1, 2, 4]) + + initb() + b.shift(1) + assertb([1, 2, 3, 4, 0]) + + initb() + b.shift(1, 1, 3) + assertb([0, 2, 3, 0, 4]) + + //rotating + initb() + b.rotate(-1); + assertb([4, 0, 1, 2, 3]) + + initb() + b.rotate(-1, 0, 3); + assertb([2, 0, 1, 3, 4]) + + initb() + b.rotate(-1, 1, 3); + assertb([0, 3, 1, 2, 4]) + + initb() + b.rotate(2) + assertb([2, 3, 4, 0, 1]) + + initb() + b.rotate(1, 1, 3) + assertb([0, 2, 3, 1, 4]) + +} From 8eb3376cf5a9ea915284b532fc795450312174f5 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Thu, 18 Aug 2016 14:26:56 +0300 Subject: [PATCH 2/6] Use embedded version of microbit to avoid yotta build --- libs/lang-test0/pxt.json | 2 +- libs/lang-test1/pxt.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/lang-test0/pxt.json b/libs/lang-test0/pxt.json index efe3da6f..f55e718d 100644 --- a/libs/lang-test0/pxt.json +++ b/libs/lang-test0/pxt.json @@ -8,6 +8,6 @@ "public": true, "additionalFilePath": "../../node_modules/pxt-core/libs/lang-test0", "dependencies": { - "microbit": "file:../microbit" + "microbit": "*" } } diff --git a/libs/lang-test1/pxt.json b/libs/lang-test1/pxt.json index 07bb8286..a38f7abf 100644 --- a/libs/lang-test1/pxt.json +++ b/libs/lang-test1/pxt.json @@ -7,6 +7,6 @@ ], "public": true, "dependencies": { - "microbit": "file:../microbit" + "microbit": "*" } } From 0c99eaf7bfd346db6194608feda33bc30ed51c3e Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Thu, 18 Aug 2016 15:31:31 +0300 Subject: [PATCH 3/6] Bump pxt-core to 0.3.40 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b859d4b1..e6e630c0 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,6 @@ "typescript": "^1.8.7" }, "dependencies": { - "pxt-core": "0.3.39" + "pxt-core": "0.3.40" } } From 24eb6f64db5a6550346a690129b4fba9a4dd037f Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Thu, 18 Aug 2016 15:31:31 +0300 Subject: [PATCH 4/6] 0.3.37 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e6e630c0..819e639f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pxt-microbit", - "version": "0.3.36", + "version": "0.3.37", "description": "micro:bit target for PXT", "keywords": [ "JavaScript", From b1cf3246aea0d699f7dd8335224aac6f5ae085dc Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Thu, 18 Aug 2016 15:55:23 +0300 Subject: [PATCH 5/6] Revert "Use embedded version of microbit to avoid yotta build" This reverts commit 8eb3376cf5a9ea915284b532fc795450312174f5. --- libs/lang-test0/pxt.json | 2 +- libs/lang-test1/pxt.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/lang-test0/pxt.json b/libs/lang-test0/pxt.json index f55e718d..efe3da6f 100644 --- a/libs/lang-test0/pxt.json +++ b/libs/lang-test0/pxt.json @@ -8,6 +8,6 @@ "public": true, "additionalFilePath": "../../node_modules/pxt-core/libs/lang-test0", "dependencies": { - "microbit": "*" + "microbit": "file:../microbit" } } diff --git a/libs/lang-test1/pxt.json b/libs/lang-test1/pxt.json index a38f7abf..07bb8286 100644 --- a/libs/lang-test1/pxt.json +++ b/libs/lang-test1/pxt.json @@ -7,6 +7,6 @@ ], "public": true, "dependencies": { - "microbit": "*" + "microbit": "file:../microbit" } } From a78f7f96017ac650b9e0bbbf0f9603e431a6724c Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Thu, 18 Aug 2016 15:55:34 +0300 Subject: [PATCH 6/6] 0.3.38 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 819e639f..ba124618 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pxt-microbit", - "version": "0.3.37", + "version": "0.3.38", "description": "micro:bit target for PXT", "keywords": [ "JavaScript",