mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00

* Get todo example running with napi. * Code review fixes. * Code review feedback. * Code review fixes. * docs fix * Update api/napi/__test__/resources/error.slint Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update api/napi/__test__/resources/test.slint Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix test --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
46 lines
No EOL
1.3 KiB
TypeScript
46 lines
No EOL
1.3 KiB
TypeScript
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
|
|
|
|
import test from 'ava'
|
|
const path = require('node:path');
|
|
|
|
import { loadFile, CompilerError, Diagnostic } from '../index'
|
|
|
|
test('loadFile', (t) => {
|
|
let demo = loadFile(path.join(__dirname, "resources/test.slint"));
|
|
let test = new demo.Test();
|
|
t.is(test.check, "Test");
|
|
|
|
let errorPath = path.join(__dirname, "resources/error.slint");
|
|
|
|
const error = t.throws(() => {
|
|
loadFile(errorPath)
|
|
},
|
|
{instanceOf: CompilerError}
|
|
);
|
|
|
|
t.is(error?.message, "Could not compile " + errorPath);
|
|
t.deepEqual(error?.diagnostics, [
|
|
{
|
|
column: 18,
|
|
level: 0,
|
|
lineNumber: 7,
|
|
message: 'Missing type. The syntax to declare a property is `property <type> name;`. Only two way bindings can omit the type',
|
|
sourceFile: errorPath
|
|
},
|
|
{
|
|
column: 22,
|
|
level: 0,
|
|
lineNumber: 7,
|
|
message: 'Syntax error: expected \';\'',
|
|
sourceFile: errorPath
|
|
},
|
|
{
|
|
column: 22,
|
|
level: 0,
|
|
lineNumber: 7,
|
|
message: 'Parse error',
|
|
sourceFile: errorPath
|
|
},
|
|
]);
|
|
}) |