Add tests, remove unused code, fix bugs

- Added tests for more error messages
- Test the "go to reference" feature at every character index of every
test case
- Delete unused code and imports
- Fix some bugs I found along the way
This commit is contained in:
James Westman 2024-12-22 18:00:39 -06:00
parent 5b0f662478
commit 9b9fab832b
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
47 changed files with 140 additions and 190 deletions

View file

@ -0,0 +1,2 @@
using Gtk 4.0;
//comment

View file

@ -0,0 +1,2 @@
using Gtk 4.0;
// comment

View file

@ -0,0 +1,5 @@
using Gtk 4.0;
Entry {
margin-bottom: 10.5;
}

View file

@ -0,0 +1 @@
4,18,4,Cannot convert 10.5 to integer

View file

@ -0,0 +1,3 @@
using Gtk 4.0;
int {}

View file

@ -0,0 +1 @@
3,1,3,int is not a class

View file

@ -0,0 +1,7 @@
using Gtk 4.0;
Overlay {
child: my_menu;
}
menu my_menu {}

View file

@ -0,0 +1 @@
4,10,7,Cannot assign Gio.Menu to Gtk.Widget

View file

@ -0,0 +1,5 @@
using Gtk 4.0;
Entry {
margin-bottom: "10";
}

View file

@ -0,0 +1 @@
4,18,4,Cannot convert string to number

View file

@ -0,0 +1,5 @@
using Gtk 4.0;
Button {
child: "Click me";
}

View file

@ -0,0 +1 @@
4,10,10,Cannot convert string to Gtk.Widget

View file

@ -0,0 +1,6 @@
using Gtk 4.0;
using Gio 2.0;
Gio.ListStore {
item-type: "Button";
}

View file

@ -0,0 +1 @@
5,14,8,Cannot convert string to GType

View file

@ -0,0 +1,5 @@
using Gtk 4.0;
Button {
child: _("Click me");
}

View file

@ -0,0 +1 @@
4,10,13,Cannot convert translated string to Gtk.Widget

View file

@ -0,0 +1,5 @@
using Gtk 4.0;
Button {
label: typeof<Button>;
}

View file

@ -0,0 +1 @@
4,10,14,Cannot convert GType to string

View file

@ -0,0 +1 @@
~

View file

@ -0,0 +1 @@
1,1,0,Could not determine what kind of syntax is meant here

View file

@ -0,0 +1,5 @@
using Gtk 4.0;
Button btn {
label: bind btn.label sync-create;
}

View file

@ -0,0 +1 @@
4,25,11,'sync-create' is now the default. Use 'no-sync-create' if this is not wanted.

View file

@ -0,0 +1,5 @@
using Gtk 4.0;
BuilderListItemFactory {
template {}
}

View file

@ -0,0 +1 @@
4,3,8,Expected type name after 'template' keyword

View file

@ -4,6 +4,7 @@ Box {
visible: bind box2.visible inverted;
orientation: bind box2.orientation;
spacing: bind box2.spacing no-sync-create;
tooltip-text: bind box2.tooltip-text bidirectional;
}
Box box2 {

View file

@ -10,6 +10,7 @@ corresponding .blp file and regenerate this file with blueprint-compiler.
<property name="visible" bind-source="box2" bind-property="visible" bind-flags="sync-create|invert-boolean"/>
<property name="orientation" bind-source="box2" bind-property="orientation" bind-flags="sync-create"/>
<property name="spacing" bind-source="box2" bind-property="spacing"/>
<property name="tooltip-text" bind-source="box2" bind-property="tooltip-text" bind-flags="sync-create|bidirectional"/>
</object>
<object class="GtkBox" id="box2">
<property name="spacing">6</property>

View file

@ -1,11 +0,0 @@
using Gtk 4.0;
Box {
visible: bind box2.visible inverted;
orientation: bind box2.orientation;
spacing: bind box2.spacing no-sync-create;
}
Box box2 {
spacing: 6;
}

View file

@ -46,3 +46,4 @@ class TestFormatter(unittest.TestCase):
self.assert_format_test("in2.blp", "out.blp")
self.assert_format_test("correct1.blp", "correct1.blp")
self.assert_format_test("string_in.blp", "string_out.blp")
self.assert_format_test("comment_in.blp", "comment_out.blp")

View file

@ -28,6 +28,7 @@ gi.require_version("Gtk", "4.0")
from gi.repository import Gtk
from blueprintcompiler import decompiler, parser, tokenizer, utils
from blueprintcompiler.ast_utils import AstNode
from blueprintcompiler.completions import complete
from blueprintcompiler.errors import (
CompileError,
@ -61,11 +62,14 @@ class TestSamples(unittest.TestCase):
except:
pass
def assert_ast_doesnt_crash(self, text, tokens, ast):
def assert_ast_doesnt_crash(self, text, tokens, ast: AstNode):
lsp = LanguageServer()
for i in range(len(text)):
ast.get_docs(i)
for i in range(len(text)):
list(complete(LanguageServer(), ast, tokens, i))
list(complete(lsp, ast, tokens, i))
for i in range(len(text)):
ast.get_reference(i)
ast.get_document_symbols()
def assert_sample(self, name, skip_run=False):