Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jeromedecoster opened this issue Jul 16, 2010 · 1 comment
Open

Comments

@jeromedecoster
Copy link

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 !

@drewbourne
Copy link
Owner

I've been thinking about that issue since I started working on hamcrest-as3. I'll try to get my thoughts down tonight. Its easily the biggest change to make as it affects every matcher, and thats why I haven't actioned anything for it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants