tests: Test the gears.matcher greater and lesser sections.
This commit is contained in:
parent
64bef57013
commit
91ca922671
|
@ -25,6 +25,8 @@
|
||||||
--
|
--
|
||||||
-- @DOC_text_gears_matcher_default_EXAMPLE@
|
-- @DOC_text_gears_matcher_default_EXAMPLE@
|
||||||
--
|
--
|
||||||
|
-- This example shows the different matching sections:
|
||||||
|
--
|
||||||
-- @DOC_text_gears_matcher_types_EXAMPLE@
|
-- @DOC_text_gears_matcher_types_EXAMPLE@
|
||||||
--
|
--
|
||||||
-- More examples are available in `awful.rules`.
|
-- More examples are available in `awful.rules`.
|
||||||
|
|
|
@ -4,6 +4,8 @@ local gears = {matcher = require("gears.matcher")} --DOC_HIDE
|
||||||
|
|
||||||
local matcher = gears.matcher()
|
local matcher = gears.matcher()
|
||||||
|
|
||||||
|
--DOC_NEWLINE
|
||||||
|
|
||||||
matcher:append_rule( "my.source", {
|
matcher:append_rule( "my.source", {
|
||||||
rule = {
|
rule = {
|
||||||
my_any_rule = true,
|
my_any_rule = true,
|
||||||
|
@ -21,6 +23,8 @@ local gears = {matcher = require("gears.matcher")} --DOC_HIDE
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
--DOC_NEWLINE
|
||||||
|
|
||||||
local candidate1 = {
|
local candidate1 = {
|
||||||
my_any_rule = true,
|
my_any_rule = true,
|
||||||
every1 = 1,
|
every1 = 1,
|
||||||
|
@ -60,3 +64,37 @@ local gears = {matcher = require("gears.matcher")} --DOC_HIDE
|
||||||
assert(candidate1.was_a_match == true )
|
assert(candidate1.was_a_match == true )
|
||||||
assert(candidate2.was_a_match == false)
|
assert(candidate2.was_a_match == false)
|
||||||
assert(candidate3.was_a_match == false)
|
assert(candidate3.was_a_match == false)
|
||||||
|
|
||||||
|
--DOC_NEWLINE
|
||||||
|
|
||||||
|
-- It is also possible to match number property by range.
|
||||||
|
matcher:append_rule( "my.source", {
|
||||||
|
rule_greater = {
|
||||||
|
value = 50,
|
||||||
|
},
|
||||||
|
rule_lesser = {
|
||||||
|
value = 100,
|
||||||
|
},
|
||||||
|
properties = {
|
||||||
|
was_a_match = true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
--DOC_NEWLINE
|
||||||
|
|
||||||
|
local candidate4 = { value = 40 , was_a_match = false }
|
||||||
|
local candidate5 = { value = 75 , was_a_match = false }
|
||||||
|
local candidate6 = { value = 101, was_a_match = false }
|
||||||
|
|
||||||
|
--DOC_NEWLINE
|
||||||
|
|
||||||
|
matcher:apply(candidate4)
|
||||||
|
matcher:apply(candidate5)
|
||||||
|
matcher:apply(candidate6)
|
||||||
|
|
||||||
|
--DOC_NEWLINE
|
||||||
|
|
||||||
|
-- Only candidate5 fits all criteria.
|
||||||
|
assert(candidate4.was_a_match == false)
|
||||||
|
assert(candidate5.was_a_match == true )
|
||||||
|
assert(candidate6.was_a_match == false)
|
||||||
|
|
Loading…
Reference in New Issue