mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
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:
parent
5b0f662478
commit
9b9fab832b
47 changed files with 140 additions and 190 deletions
2
tests/formatting/comment_in.blp
Normal file
2
tests/formatting/comment_in.blp
Normal file
|
@ -0,0 +1,2 @@
|
|||
using Gtk 4.0;
|
||||
//comment
|
2
tests/formatting/comment_out.blp
Normal file
2
tests/formatting/comment_out.blp
Normal file
|
@ -0,0 +1,2 @@
|
|||
using Gtk 4.0;
|
||||
// comment
|
5
tests/sample_errors/float_to_int_assignment.blp
Normal file
5
tests/sample_errors/float_to_int_assignment.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Entry {
|
||||
margin-bottom: 10.5;
|
||||
}
|
1
tests/sample_errors/float_to_int_assignment.err
Normal file
1
tests/sample_errors/float_to_int_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,18,4,Cannot convert 10.5 to integer
|
3
tests/sample_errors/int_object.blp
Normal file
3
tests/sample_errors/int_object.blp
Normal file
|
@ -0,0 +1,3 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
int {}
|
1
tests/sample_errors/int_object.err
Normal file
1
tests/sample_errors/int_object.err
Normal file
|
@ -0,0 +1 @@
|
|||
3,1,3,int is not a class
|
7
tests/sample_errors/menu_assignment.blp
Normal file
7
tests/sample_errors/menu_assignment.blp
Normal file
|
@ -0,0 +1,7 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Overlay {
|
||||
child: my_menu;
|
||||
}
|
||||
|
||||
menu my_menu {}
|
1
tests/sample_errors/menu_assignment.err
Normal file
1
tests/sample_errors/menu_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,10,7,Cannot assign Gio.Menu to Gtk.Widget
|
5
tests/sample_errors/string_to_num_assignment.blp
Normal file
5
tests/sample_errors/string_to_num_assignment.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Entry {
|
||||
margin-bottom: "10";
|
||||
}
|
1
tests/sample_errors/string_to_num_assignment.err
Normal file
1
tests/sample_errors/string_to_num_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,18,4,Cannot convert string to number
|
5
tests/sample_errors/string_to_object_assignment.blp
Normal file
5
tests/sample_errors/string_to_object_assignment.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Button {
|
||||
child: "Click me";
|
||||
}
|
1
tests/sample_errors/string_to_object_assignment.err
Normal file
1
tests/sample_errors/string_to_object_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,10,10,Cannot convert string to Gtk.Widget
|
6
tests/sample_errors/string_to_type_assignment.blp
Normal file
6
tests/sample_errors/string_to_type_assignment.blp
Normal file
|
@ -0,0 +1,6 @@
|
|||
using Gtk 4.0;
|
||||
using Gio 2.0;
|
||||
|
||||
Gio.ListStore {
|
||||
item-type: "Button";
|
||||
}
|
1
tests/sample_errors/string_to_type_assignment.err
Normal file
1
tests/sample_errors/string_to_type_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
5,14,8,Cannot convert string to GType
|
5
tests/sample_errors/translated_assignment.blp
Normal file
5
tests/sample_errors/translated_assignment.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Button {
|
||||
child: _("Click me");
|
||||
}
|
1
tests/sample_errors/translated_assignment.err
Normal file
1
tests/sample_errors/translated_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,10,13,Cannot convert translated string to Gtk.Widget
|
5
tests/sample_errors/typeof_assignment.blp
Normal file
5
tests/sample_errors/typeof_assignment.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Button {
|
||||
label: typeof<Button>;
|
||||
}
|
1
tests/sample_errors/typeof_assignment.err
Normal file
1
tests/sample_errors/typeof_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,10,14,Cannot convert GType to string
|
1
tests/sample_errors/unrecognized_syntax.blp
Normal file
1
tests/sample_errors/unrecognized_syntax.blp
Normal file
|
@ -0,0 +1 @@
|
|||
~
|
1
tests/sample_errors/unrecognized_syntax.err
Normal file
1
tests/sample_errors/unrecognized_syntax.err
Normal file
|
@ -0,0 +1 @@
|
|||
1,1,0,Could not determine what kind of syntax is meant here
|
5
tests/sample_errors/upgrade_sync_create.blp
Normal file
5
tests/sample_errors/upgrade_sync_create.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Button btn {
|
||||
label: bind btn.label sync-create;
|
||||
}
|
1
tests/sample_errors/upgrade_sync_create.err
Normal file
1
tests/sample_errors/upgrade_sync_create.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,25,11,'sync-create' is now the default. Use 'no-sync-create' if this is not wanted.
|
5
tests/sample_errors/upgrade_template_list_item.blp
Normal file
5
tests/sample_errors/upgrade_template_list_item.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BuilderListItemFactory {
|
||||
template {}
|
||||
}
|
1
tests/sample_errors/upgrade_template_list_item.err
Normal file
1
tests/sample_errors/upgrade_template_list_item.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,3,8,Expected type name after 'template' keyword
|
|
@ -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 {
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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")
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue