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

Partial mocks throw error when an unstubbed getter returning Vector is called #67

Open
ericklaus-wf opened this issue Jul 1, 2013 · 0 comments

Comments

@ericklaus-wf
Copy link

Only unstubbed properties exhibit this bug. Methods and stubbed properties can be retrieved as expected.

The failing unit test will throw "Error #1065: Variable __AS3__vec::Vector. is not defined."

public class PartialMockVectorError
{
    [Rule]
    public var mocks:MockolateRule = new MockolateRule();

    [Mock(type="partial")]
    public var vectorWrapper:ClassWithVector;

    [Test]
    public function testShouldGetVector():void
    {
        //fails
        vectorWrapper.someList;
    }

    [Test]
    public function testStubbedPropertyShouldGetVector():void
    {
        //passes
        var vector:Vector.<String> = new Vector.<String>();
        stub(vectorWrapper).getter("someList").returns(vector);
        assertTrue(vectorWrapper.someList === vector);
    }

    [Test]
    public function testMethodShouldGetVector():void
    {
        //passes
        vectorWrapper.retrieveSomeList();
    }
}

public class ClassWithVector
{

    private var _someList:Vector.<String>;

    public function ClassWithVector():void
    {
        _someList = new Vector.<String>();
    }

    public function get someList():Vector.<String>
    {
        return _someList;
    }

    public function set someList(value:Vector.<String>):void
    {
        _someList = value;
    }

    public function retrieveSomeList():Vector.<String>
    {
        return _someList;
    }
}
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

1 participant