Skip to content

Commit

Permalink
Fix/update to bsc 0.59.0 (#192)
Browse files Browse the repository at this point in the history
* bump

* update to bsc 0.59.0

* update to latest bsc
  • Loading branch information
georgejecook authored Nov 4, 2022
1 parent eef1a37 commit fdbc7ba
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 125 deletions.
7 changes: 7 additions & 0 deletions bsc-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [5.2.3](https://github.com/georgejecook/rooibos/compare/5.2.2...5.2.3)

- Make "undent" a prod dependency [`#186`](https://github.com/georgejecook/rooibos/pull/186)

#### [5.2.2](https://github.com/georgejecook/rooibos/compare/5.2.1...5.2.2)

> 15 June 2022
- fix(asserts): fixes logic error in assertclass [`#179`](https://github.com/georgejecook/rooibos/pull/179)
- bump [`f47052f`](https://github.com/georgejecook/rooibos/commit/f47052f5844c588c58194505e94614507b7d89d3)

#### [5.2.1](https://github.com/georgejecook/rooibos/compare/5.2.0...5.2.1)

Expand Down
2 changes: 1 addition & 1 deletion bsc-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/node": "^17.0.29",
"@typescript-eslint/eslint-plugin": "^4.4.1",
"@typescript-eslint/parser": "^4.4.1",
"brighterscript": "^0.52.1",
"brighterscript": "^0.59.0",
"chai": "^4.2.0",
"chai-subset": "^1.6.0",
"coveralls": "^3.0.0",
Expand Down
16 changes: 9 additions & 7 deletions bsc-plugin/src/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { BrsFile, CallExpression, ClassMethodStatement, ClassStatement, Exp
import { CallfuncExpression, DiagnosticSeverity, DottedGetExpression, Program, ProgramBuilder, util, standardizePath as s, PrintStatement } from 'brighterscript';
import { expect } from 'chai';
import { RooibosPlugin } from './plugin';
import PluginInterface from 'brighterscript/dist/PluginInterface';
import * as fsExtra from 'fs-extra';
import * as path from 'path';
import * as trim from 'trim-whitespace';
Expand Down Expand Up @@ -621,7 +620,7 @@ describe('RooibosPlugin', () => {
@it("test1")
function _()
b = { someValue: lib.myEnum.value}
m.assertEqual(a, { someValue: lib.myEnum.value})
m.assertEqual(b, { someValue: lib.myEnum.value})
end function
end class
`);
Expand All @@ -637,7 +636,7 @@ describe('RooibosPlugin', () => {
}
m.currentAssertLineNumber = 12
m.assertEqual(a, {
m.assertEqual(b, {
someValue: "value"
})
if m.currentResult.isFail then return invalid`);
Expand Down Expand Up @@ -889,6 +888,7 @@ describe('RooibosPlugin', () => {
@describe("groupA")
@it("test1")
function _()
thing = {}
m.expectNotCalled([email protected]())
m.expectNotCalled([email protected]("arg1", "arg2"))
end function
Expand All @@ -901,24 +901,26 @@ describe('RooibosPlugin', () => {
expect(
getTestFunctionContents()
).to.eql(undent`
m.currentAssertLineNumber = 6
thing = {}
m.currentAssertLineNumber = 7
m._expectNotCalled(thing, "callFunc", thing, "thing")
if m.currentResult.isFail then return invalid
m.currentAssertLineNumber = 7
m.currentAssertLineNumber = 8
m._expectNotCalled(thing, "callFunc", thing, "thing")
if m.currentResult.isFail then return invalid
`);
//verify original code does not remain modified after the transpile cycle
const testMethod = ((file.ast.statements[0] as ClassStatement).memberMap['_'] as ClassMethodStatement);

const call1 = (testMethod.func.body.statements[0] as ExpressionStatement).expression as CallExpression;
const call1 = (testMethod.func.body.statements[1] as ExpressionStatement).expression as CallExpression;
expect(call1.args).to.be.lengthOf(1);
expect(call1.args[0]).to.be.instanceof(CallfuncExpression);
expect((call1.args[0] as CallfuncExpression).methodName.text).to.eql('getFunction');

const call2 = (testMethod.func.body.statements[0] as ExpressionStatement).expression as CallExpression;
const call2 = (testMethod.func.body.statements[2] as ExpressionStatement).expression as CallExpression;
expect(call2.args).to.be.lengthOf(1);
expect(call2.args[0]).to.be.instanceof(CallfuncExpression);
expect((call2.args[0] as CallfuncExpression).methodName.text).to.eql('getFunction');
Expand Down
4 changes: 1 addition & 3 deletions bsc-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ export class RooibosPlugin implements CompilerPlugin {
}
}

beforePublish() { }

beforeProgramTranspile(program: Program, entries: TranspileObj[], editor: AstEditor) {
this.session.addTestRunnerMetadata(editor);
this.session.addLaunchHook(editor);
Expand Down Expand Up @@ -126,7 +124,7 @@ export class RooibosPlugin implements CompilerPlugin {
this.session.removeRooibosMain();
}

afterProgramValidate() {
afterProgramValidate(program: Program) {
// console.log('bpv');
this.session.updateSessionStats();
for (let testSuite of [...this.session.sessionInfo.testSuites.values()]) {
Expand Down
2 changes: 1 addition & 1 deletion framework/src/source/BaseTestSuite.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1874,10 +1874,10 @@ namespace rooibos
expectedArgsValues = []
lineNumber = m.currentAssertLineNumber
hasArgs = Rooibos.Common.isArray(expectedArgs)
defaultValue = m.ignoreValue
if hasArgs
defaultValue = m.invalidValue
else
defaultValue = m.ignoreValue
expectedArgs = []
end if
lineNumbers = [lineNumber]
Expand Down
8 changes: 4 additions & 4 deletions framework/src/source/CommonUtils.bs
Original file line number Diff line number Diff line change
Expand Up @@ -803,26 +803,26 @@ namespace rooibos.Common
contentName = parts[i]
i++
if type(content) <> "roAssociativeArray"
content = {id: contentName}
content = { id: contentName }
end if
part = content
while i < numParts and part <> invalid
isIndexNumber = parts[i] = "0" or (parts[i].toInt() <> 0 and parts[i].toInt().toStr() = parts[i])
index = invalid
if isIndexNumber
index = parts[i].toInt()
else
index = parts[i]
end if

nextPart = invalid
if rooibos.Common.isArray(part) and isIndexNumber
nextPart = part[index]
else if type(part) = "roAssociativeArray" and not isIndexNumber
nextPart = part[index]
else
nextPart = invalid
end if

if nextPart = invalid or type(nextPart) <> "roAssociativeArray"
if nextPart = invalid or type(nextPart) <> "roAssociativeArray"
if (not isIndexNumber and type(part) = "roAssociativeArray") or (isIndexNumber and (rooibos.Common.isArray(part)))
nextPart = { id: index }
part[index] = nextPart
Expand Down
8 changes: 5 additions & 3 deletions framework/src/source/ConsoleTestReporter.bs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace rooibos
private lineWidth = 60

function new(testRunner)
'bs:disable-next-line
super(testRunner)
if m.config.lineWidth <> invalid
m.lineWidth = m.config.lineWidth
Expand Down Expand Up @@ -48,7 +49,7 @@ namespace rooibos
m.printLine()
m.printLine()
end if

overrallResult = ""
if m.allStats.hasFailures
overrallResult = "Fail"
else
Expand Down Expand Up @@ -82,6 +83,7 @@ namespace rooibos
testLocationLine = StrI(test.lineNumber).trim()

locationLine = invalid
testChar = ""
if test.result.isCrash
testChar = "|"
locationLine = StrI(test.lineNumber).trim()
Expand All @@ -95,10 +97,9 @@ namespace rooibos

testLocationText = "file://" + test.testSuite.filePath.trim() + ":" + testLocationLine

timeText = ""
if m.config.printTestTimes = true
timeText = " (" + stri(test.result.time).trim() + "ms)"
else
timeText = ""
end if

insetText = ""
Expand All @@ -119,6 +120,7 @@ namespace rooibos
if test.isParamTest = true
insetText = " "

rawParams = invalid
if type(test.rawParams) = "roAssociativeArray"
rawParams = {}
for each key in test.rawParams
Expand Down
Loading

0 comments on commit fdbc7ba

Please sign in to comment.