Skip to content

Commit 7aaaa62

Browse files
authored
test(musicxml): Activate MusicXML Test Suite (#2012)
1 parent 42e5105 commit 7aaaa62

462 files changed

Lines changed: 11981 additions & 3970 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ jobs:
2121
- run: npm install
2222
- run: npm run build
2323
- run: npm run test
24+
id: test
25+
- uses: actions/upload-artifact@v4
26+
if: ${{ failure() && steps.test.conclusion == 'failure' }}
27+
with:
28+
name: test-results-web
29+
path: |
30+
test-data/**/*.new.png
31+
test-data/**/*.diff.png
2432
2533
build_csharp:
2634
name: Build and Test C#
@@ -38,6 +46,14 @@ jobs:
3846
- run: npm install
3947
- run: npm run build-csharp
4048
- run: npm run test-csharp
49+
id: test
50+
- uses: actions/upload-artifact@v4
51+
if: ${{ failure() && steps.test.conclusion == 'failure' }}
52+
with:
53+
name: test-results-csharp
54+
path: |
55+
test-data/**/*.new.png
56+
test-data/**/*.diff.png
4157
4258
build_kotlin:
4359
name: Build and Test Kotlin
@@ -68,4 +84,12 @@ jobs:
6884
- run: npm install
6985
- run: npm run build-kotlin
7086
- run: npm run test-kotlin
87+
id: test
88+
- uses: actions/upload-artifact@v4
89+
if: ${{ failure() && steps.test.conclusion == 'failure' }}
90+
with:
91+
name: test-results-kotlin
92+
path: |
93+
test-data/**/*.new.png
94+
test-data/**/*.diff.png
7195
- run: ./src.kotlin/alphaTab/gradlew --stop

src.compiler/AstPrinterBase.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ export default abstract class AstPrinterBase {
211211
this.writeCommaSeparated(expr.typeArguments, t => this.writeType(t));
212212
this.write('>');
213213
}
214+
215+
if(expr.nullSafe) {
216+
this.write('?.');
217+
this.write(this._context.toMethodName("invoke"))
218+
}
219+
214220
this.write('(');
215221
if (expr.arguments.length > 5) {
216222
this.writeLine();

src.compiler/csharp/CSharpAst.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ export interface PrimitiveTypeNode extends TypeNode {
311311

312312
// Expressions
313313

314-
export interface Expression extends Node {}
314+
export interface Expression extends Node { }
315315

316316
export interface PrefixUnaryExpression extends Node {
317317
nodeType: SyntaxKind.PrefixUnaryExpression;
@@ -337,7 +337,7 @@ export interface ThisLiteral extends Node {
337337
nodeType: SyntaxKind.ThisLiteral;
338338
}
339339

340-
export interface BaseLiteralExpression extends Node {}
340+
export interface BaseLiteralExpression extends Node { }
341341

342342
export interface StringLiteral extends Node {
343343
nodeType: SyntaxKind.StringLiteral;
@@ -441,6 +441,7 @@ export interface InvocationExpression extends Node {
441441
expression: Expression;
442442
arguments: Expression[];
443443
typeArguments?: TypeNode[];
444+
nullSafe?: Boolean;
444445
}
445446

446447
export interface NewExpression extends Node {
@@ -485,7 +486,7 @@ export interface YieldExpression extends Node {
485486

486487
// Statements
487488

488-
export interface Statement extends Node {}
489+
export interface Statement extends Node { }
489490

490491
export interface Block extends Statement {
491492
nodeType: SyntaxKind.Block;

src.compiler/csharp/CSharpAstTransformer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3705,7 +3705,8 @@ export default class CSharpAstTransformer {
37053705
expression: {} as cs.Expression,
37063706
parent: parent,
37073707
tsNode: expression,
3708-
nodeType: cs.SyntaxKind.InvocationExpression
3708+
nodeType: cs.SyntaxKind.InvocationExpression,
3709+
nullSafe: !!expression.questionDotToken
37093710
} as cs.InvocationExpression;
37103711

37113712
// chai

src.compiler/typescript/Serializer.setProperty.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ function generateSetPropertyBody(serializable: TypeSchema, importer: (name: stri
264264
if (collectionAddMethod) {
265265
caseStatements.push(
266266
createNodeFromSource<ts.ForOfStatement>(
267-
`for (const i of (v as unknown[])) {
268-
obj.${collectionAddMethod}(i as ${elementTypeName});
267+
`for (const i of (v as ${elementTypeName}[])) {
268+
obj.${collectionAddMethod}(i);
269269
}`,
270270
ts.SyntaxKind.ForOfStatement
271271
)

src.kotlin/alphaTab/android/src/main/java/alphaTab/collections/DoubleList.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ public class DoubleList : IDoubleIterable {
3030
_size = elements.size
3131
}
3232

33+
internal constructor(elements: IDoubleIterable) {
34+
_items = DoubleArray(0)
35+
_size = 0
36+
for(d in elements) {
37+
push(d)
38+
}
39+
}
40+
41+
3342
private constructor(elements: DoubleArray, size: Int) {
3443
_items = elements
3544
_size = size
@@ -150,7 +159,7 @@ public class DoubleList : IDoubleIterable {
150159
}
151160
}
152161

153-
162+
154163
internal fun reduce(operation: (acc: Double, v: Double) -> Double, initial:Double): Double {
155164
var accumulator = initial
156165
for (element in _items) accumulator = operation(accumulator, element)

src.kotlin/alphaTab/android/src/main/java/alphaTab/core/Globals.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ internal inline fun Int?.toDouble(): Double? {
202202

203203
internal inline fun String.toDoubleOrNaN(): Double {
204204
try {
205-
val number = NumberFormat.getInstance(Locale.ROOT).parse(this)
205+
val number = NumberFormat.getInstance(Locale.ROOT).parse(this.trim())
206206
if (number != null) {
207207
return number.toDouble()
208208
}
@@ -213,7 +213,7 @@ internal inline fun String.toDoubleOrNaN(): Double {
213213

214214
internal fun String.toIntOrNaN(): Double {
215215
try {
216-
val number = NumberFormat.getInstance(Locale.ROOT).parse(this)
216+
val number = NumberFormat.getInstance(Locale.ROOT).parse(this.trim())
217217
if (number != null) {
218218
return number.toInt().toDouble()
219219
}
@@ -224,7 +224,7 @@ internal fun String.toIntOrNaN(): Double {
224224

225225
internal fun String.toIntOrNaN(radix: Double): Double {
226226
try {
227-
return Integer.parseInt(this, radix.toInt()).toDouble();
227+
return Integer.parseInt(this.trim(), radix.toInt()).toDouble();
228228
} catch (e: Throwable) {
229229
}
230230
return Double.NaN

src.kotlin/alphaTab/android/src/main/java/alphaTab/core/ecmaScript/Array.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package alphaTab.core.ecmaScript
22

3+
import alphaTab.collections.IDoubleIterable
4+
35
@Suppress("NOTHING_TO_INLINE")
46
internal class Array {
57
companion object {
68
public inline fun <T> from(x: Iterable<T>): alphaTab.collections.List<T> {
79
return alphaTab.collections.List(x)
810
}
11+
public inline fun from(x: IDoubleIterable): alphaTab.collections.DoubleList {
12+
return alphaTab.collections.DoubleList(x)
13+
}
914
public inline fun isArray(x:Any?):Boolean {
1015
return x is alphaTab.collections.List<*>
1116
}
Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,50 @@
11
package alphaTab.core.ecmaScript
22

3+
import alphaTab.collections.ObjectBooleanMap
4+
35
public class Set<T> : Iterable<T> {
4-
private val _set: HashSet<T>
6+
private val _storage: ObjectBooleanMap<T>
57

68
public constructor() {
7-
_set = HashSet()
9+
_storage = ObjectBooleanMap()
810
}
911

1012
public val size : Double
11-
get() = _set.size.toDouble()
13+
get() = _storage.size.toDouble()
1214

1315
public constructor(values: Iterable<T>?) {
14-
_set = values?.toHashSet() ?: HashSet()
16+
_storage = ObjectBooleanMap()
17+
if(values != null){
18+
for(v in values) {
19+
add(v)
20+
}
21+
}
22+
1523
}
1624

1725
public fun add(item: T) {
18-
_set.add(item)
26+
_storage.set(item, true)
1927
}
2028

2129
public fun has(item: T): Boolean {
22-
return _set.contains(item)
30+
return _storage.has(item)
2331
}
2432

2533
public fun delete(item: T) {
26-
_set.remove(item)
34+
_storage.delete(item)
2735
}
2836

2937
public fun forEach(action: (item: T) -> Unit) {
30-
for (i in _set) {
38+
for (i in _storage.keys()) {
3139
action(i)
3240
}
3341
}
3442

3543
override fun iterator(): Iterator<T> {
36-
return _set.iterator()
44+
return _storage.keys().iterator()
3745
}
3846

3947
fun clear() {
40-
_set.clear()
48+
_storage.clear()
4149
}
4250
}

src/generated/model/TrackSerializer.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ export class TrackSerializer {
3333
o.set("shortname", obj.shortName);
3434
o.set("defaultsystemslayout", obj.defaultSystemsLayout);
3535
o.set("systemslayout", obj.systemsLayout);
36+
if (obj.lineBreaks !== undefined) {
37+
const a: number[] = [];
38+
o.set("linebreaks", a);
39+
for (const v of obj.lineBreaks!) {
40+
a.push(v);
41+
}
42+
}
3643
o.set("percussionarticulations", obj.percussionArticulations.map(i => InstrumentArticulationSerializer.toJson(i)));
3744
if (obj.style) {
3845
o.set("style", TrackStyleSerializer.toJson(obj.style));
@@ -70,6 +77,11 @@ export class TrackSerializer {
7077
case "systemslayout":
7178
obj.systemsLayout = v! as number[];
7279
return true;
80+
case "linebreaks":
81+
for (const i of (v as number[])) {
82+
obj.addLineBreaks(i);
83+
}
84+
return true;
7385
case "percussionarticulations":
7486
obj.percussionArticulations = [];
7587
for (const o of (v as (Map<string, unknown> | null)[])) {

0 commit comments

Comments
 (0)