Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Enhancement: Better way to test enums #157

Closed
raineorshine opened this issue May 14, 2016 · 2 comments
Closed

Enhancement: Better way to test enums #157

raineorshine opened this issue May 14, 2016 · 2 comments

Comments

@raineorshine
Copy link
Contributor

Unless there is a global available to tests that I am not aware of, enums are only understood as uint types (as they are compiled to):

it('should have a myEnum property', () => {
  var contract = MyContract.deployed()
  return contract.myEnum.call(accounts[0]).then(myEnumResult => {
    assert.equal(myEnumResult.valueOf(), 1)
  })
})

It would be better to have something like this so that the test was not tightly coupled to the enum's underlying integer values:

assert.equal(myEnumResult.valueOf(), contract.deployed().MyEnum.SomeValue)

Is this feasible? Would you have to parse the Solidity yourself since the deployed contract just treats enums as uint's?

@tcoulter
Copy link
Contributor

Likely feasible if the enums are described in the contract's ABI. This would be a feature update for ether-pudding, however.

@sebs
Copy link

sebs commented Aug 30, 2016

----- removed offtopic

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

No branches or pull requests

3 participants