misprintt / mockatoo

A cross platform mocking framework for Haxe. Supports JavaScript, Flash, C++, PHP and Neko.
MIT License
49 stars 31 forks source link

Class not found : tink.macro.tools.MacroTools #22

Closed rukbotto closed 10 years ago

rukbotto commented 11 years ago

Hi there,

I'm trying to run this test case:

package entities;

import massive.munit.Assert;
import utils.GameMap;
import mockatoo.Mockatoo.spy;

class VillagerTest
{
    private var villager:Villager;

    public function new()
    {

    }

    @Before
    public function setUp()
    {
        var map = spy(GameMap);
        map.getTileXPos().returns(20);
        map.getTileYPos().returns(20);
        map.tileWidth.returns(10);
        map.tileHeight.returns(10);
        villager = new Villager(2, 2, map);
    }

    @Test
    public function testVillagerCreation()
    {
        Assert.areEqual(10, villager.width);
        Assert.areEqual(10, villager.height);
        Assert.areEqual(20, villager.x);
        Assert.areEqual(20, villager.y);
    }
}

But I'm hitting this exception when running the above test case with munit:

$ haxelib run munit test
Massive Unit - Copyright 2013 Massive Interactive. Version 2.1.0
   haxe -main TestMain -lib munit -lib mockatoo -lib openfl -lib haxepunk -lib hamcrest -cp src -cp test -swf-version 11 -swf build/as3_test.swf
   /usr/lib/haxe/lib/mockatoo/2,1,1/mockatoo/macro/MockMaker.hx:8: characters 7-34 : Class not found : tink.macro.tools.MacroTools
test/entities/VillagerTest.hx:8: lines 8-36 : Defined in this class
Error: Error compiling hxml for as3
Target as3 /project/path/build/as3_test.swf

I checked further and found tink.macro.tools.MacroTools is not present in tink_macro package. However, it is present in tinker_macros package, which is not available for Haxe 3.

misprintt commented 11 years ago

Hi,

The 0.0.x -beta release of tink macros on haxelib (released last week) had a number of breaking changes to packages and classes.

Unfortunately running Mockatoo in haxe 3 is depend on these (unstable) 0.x versions of tink macros (the haxe 2 versions were a proper 1.x release).

I will try to update this dependency in the near future, but your best option right now is to switch back to an earlier version of tink macros 0,0.x on haxelib

jasononeil commented 10 years ago

I started making some of the changes:

https://github.com/jasononeil/mockatoo/tree/new_tink

I got it compiling for my thing, but the unit tests don't compile. As an example, in the MockatooStubbingTest.should_generate_returns() test:

    Mockatoo.returns(instance.toString(), "foo");
    instance.toString().returns("bar");

these should both do the same thing. The first works, the second gives:

    Invalid expression [@:this this]

Trying to trace the differences, I was looking in StubbingMacro.returns, and the difference between those two calls was:

I have no idea why this is happening... going to leave it for now. If anyone wants to continue though I thought maybe what I'd found so far might be helpful.

Mitchal commented 10 years ago

Thanks for a superb mocking framework!

Unfortunately it stopped working for me as well when I updated the tink_* libs. What versions of tink_core and tink_macro do I need to have in order for mockatoo to work?

misprintt commented 10 years ago

It should run against these versions in Haxe 3.0:

jasononeil commented 10 years ago

I ran into this while looking through the new Haxe manual, probably related when me (or someone) gets around to trying to patch mockatoo to work with latest tink, and apparently, latest Haxe development versions:

since Haxe 3.1.0

The combination of static extensions and macros was reworked for the 3.1.0 release. The Haxe Compiler does not even try to find the original expression for the macro argument and instead passes a special @:this this expression. While the structure of this expression conveys no information, the expression can still be typed correctly:

...

http://haxe.jasono.co/manual/macro-limitations-static-extension.html

misprintt commented 10 years ago

Closing this as mockatoo 3.0.x (on master) no longer depends on tink_macros, and is compatible with Haxe 3.1.x