Skip to content

MXML Matchers have cool options that pure as3 matchers don't have #34

@jeromedecoster

Description

@jeromedecoster

Hello,
If I compile your MXML example :
<core:AllOf id="numberMatcher" target="{ Number(numberInput.text) }">
<object:NotNull />
core:AnyOf
<object:EqualTo value="17" />
<number:CloseTo value="11" delta="0.3" />
<number:Between min="1" max="9" />
/core:AnyOf
/core:AllOf

<mx:TextInput id="numberInput" />
<mx:Label text="{ numberMatcher.description }" />
<mx:Label text="{ numberMatcher.mismatchDescription }" />
<mx:Label text="{ numberMatcher.matched }" />

If you decompile it, you can see, for the "closeTo" part :

public function _Test1_CloseTo1_c() : CloseTo
    {
        var _loc_1:* = new CloseTo();
        _loc_1.value = 11;
        _loc_1.delta = 0.3;
        _loc_1.initialized(this, null);
        return _loc_1;
    }

That's nice to see that we can change the properties "value" and "delta" at runtime.
Unfortunatly, we can't do that in pure as3 projects.

The IsCloseToMatcher has no getter/setter for those properties :
http://github.com/drewbourne/hamcrest-as3/blob/master/hamcrest/src/org/hamcrest/number/IsCloseToMatcher.as#L36

I think it could be very handy if we could also do it in pure as3.

//

Also the AnyOf matcher.
In decompiled Flex :
public function _Test1_AnyOf1_c() : AnyOf
{
var _loc_1:* = new AnyOf();
_loc_1.matchers = [_Test1_EqualTo1_c(), _Test1_CloseTo1_c(), _Test1_Between1_c()];
_loc_1.initialized(this, null);
return _loc_1;
}

The getter "matchers" is really handy if you want add/remove matchers at runtime.

in pure as3 you are forced to do this in one line :
anyOf(equalTo("bad"), equalTo("good"));

not easy if you want create it/update it at runtime.

What do you think ? Good idea ?

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions