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

* Export interpreter stuff on private_api namespace * Update api/napi/src/interpreter/value.rs Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update tests/driver/napi/build.rs Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com> * Update tests/driver/napi/Cargo.toml Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com> * Avoid unwanted prompt on Windows when running npm run build twice Don't generate "napi.js" as then Windows will try to open it when running just "napi", if nodejs registered .js as extension. * Remove windows path workaround It doesn't look like that it is needed. --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com> Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
58 lines
No EOL
1.7 KiB
TypeScript
58 lines
No EOL
1.7 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
|
|
},
|
|
]);
|
|
})
|
|
|
|
test('constructor parameters', (t) => {
|
|
let demo = loadFile(path.join(__dirname, "resources/test-constructor.slint"));
|
|
let hello = "";
|
|
let test = new demo.Test({ say_hello: function() { hello = "hello"; }, check: "test"});
|
|
|
|
// test.say_hello.setHandler(function () { blub = "hello"; });
|
|
test.say_hello();
|
|
|
|
t.is(test.check, "test");
|
|
t.is(hello, "hello");
|
|
}) |