Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplified sub mappings to widget constructors (#108)
* Add :subs option, export subroutine aliases for widget constructors Now when you do: use GTK::Simple :subs; you can subsequently call the constructor of any widget via a simplified version of it's name: my $button = button(label => "Shorter"); my $list-box = list-box; my $file-chooser-button = file-chooser-button(label => "File?"); The pattern is a simple conversion from camel case to kebab case. Delicious! This also fixes the issue of needing to `use GTK::Simple::App;` on a separate line. Now it is available immediately. * In recognition of not needing 'use GTK::Simple::App' * Add complete tests * Update README * Bump minor version. Use the same guard as existing tests * Avoid a merge conflict with the test.yaml branch * Whitespace change to trigger CI/CD
- Loading branch information
Showing
5 changed files
with
71 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
use v6; | ||
use Test; | ||
use GTK::Simple; | ||
use GTK::Simple::App; | ||
use GTK::Simple::Scheduler; | ||
|
||
plan *; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use v6.d; | ||
use Test; | ||
|
||
plan *; | ||
|
||
use GTK::Simple :subs; | ||
|
||
if %*ENV<DISPLAY> or $*DISTRO.is-win { | ||
# We need to create app first | ||
my $app; | ||
lives-ok { $app = app }, "There is a subroutine in scope called 'app'"; | ||
ok $app ~~ GTK::Simple::App, "'app' returns a GTK::Simple::App object"; | ||
|
||
# Other modules are pulled into GTK::Simple namespace by now that we do not want to test | ||
sub skip-test($name) { | ||
state $skip-set = set '&' X~ <app simple raw native-lib g-d-k common property-facade>; | ||
$name (elem) $skip-set | ||
} | ||
|
||
for GTK::Simple::.kv -> $name, $class { | ||
my $sub-name = '&' ~ ($name ~~ / (<:Lu><:Ll>*)* /).values.map({ .Str.lc }).join("-"); | ||
next if skip-test($sub-name); | ||
|
||
my $widget; | ||
lives-ok { $widget = ::{$sub-name}(:label("For Button(s)"), :uri("For LinkButton")) }, | ||
"There is a subroutine in scope called '$sub-name'"; | ||
ok $widget ~~ $class, "'$sub-name' returns a { $class.^name } object"; | ||
} | ||
} | ||
|
||
done-testing; |