mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-06 16:19:07 -04:00
language: Add closure expressions
This commit is contained in:
parent
5cf9b63547
commit
59aa054c4c
10 changed files with 96 additions and 7 deletions
5
tests/sample_errors/expr_closure_not_cast.blp
Normal file
5
tests/sample_errors/expr_closure_not_cast.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Label {
|
||||
label: bind $closure();
|
||||
}
|
1
tests/sample_errors/expr_closure_not_cast.err
Normal file
1
tests/sample_errors/expr_closure_not_cast.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,15,10,Closure expression must be cast to the closure's return type
|
5
tests/samples/expr_closure.blp
Normal file
5
tests/samples/expr_closure.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Label my-label {
|
||||
label: bind ($my-closure(my-label.margin-bottom)) as (string);
|
||||
}
|
13
tests/samples/expr_closure.ui
Normal file
13
tests/samples/expr_closure.ui
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkLabel" id="my-label">
|
||||
<binding name="label">
|
||||
<closure function="my-closure" type="gchararray">
|
||||
<lookup name="margin-bottom" type="GtkLabel">
|
||||
<constant>my-label</constant>
|
||||
</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</interface>
|
|
@ -151,6 +151,7 @@ class TestSamples(unittest.TestCase):
|
|||
self.assert_sample("combo_box_text")
|
||||
self.assert_sample("comments")
|
||||
self.assert_sample("enum")
|
||||
self.assert_sample("expr_closure", skip_run=True) # The closure doesn't exist
|
||||
self.assert_sample("expr_lookup")
|
||||
self.assert_sample("file_filter")
|
||||
self.assert_sample("flags")
|
||||
|
@ -208,6 +209,7 @@ class TestSamples(unittest.TestCase):
|
|||
self.assert_sample_error("empty")
|
||||
self.assert_sample_error("enum_member_dne")
|
||||
self.assert_sample_error("expr_cast_conversion")
|
||||
self.assert_sample_error("expr_closure_not_cast")
|
||||
self.assert_sample_error("expr_lookup_dne")
|
||||
self.assert_sample_error("expr_lookup_no_properties")
|
||||
self.assert_sample_error("filters_in_non_file_filter")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue