martinheidegger / as3-commons

Automatically exported from code.google.com/p/as3-commons
0 stars 0 forks source link

Inconsistent trimming of 'name' in Enum class #103

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create an enum with an name that has white space at the start or end of the 
name. For example:  MONDAY:Day = new DAY("MONDAY ")
2. Call getEnum with the value returned by the name property: Enum.getEnum(Day, 
Day.MONDAY.name)
3. The enum is not found and an exception is thrown

What is the expected output? What do you see instead?
The enum should be found and returned by the getEnum function

What version of the product are you using? On what operating system?
v0.3.5

Please provide any additional information below.
The issue is that the name is inconsistently trimmed. In the set name function, 
the value passed in is trimmed before being assigned to the _name property. 
However, the untrimmed value is then passed to the initializeEnum(String) 
function. So the enum is stored in the values array using the untrimmed name 
when its actual name is trimmed. 

The fix is to pass in the trimmed value to the initializeEnum(String) function 
in the name setter.

I've attached a patch which has a unit test to exploit the issue as well as the 
(simple) fix.

Original issue reported on code.google.com by scsi_dev...@yahoo.com on 15 Oct 2011 at 5:11

Attachments:

GoogleCodeExporter commented 9 years ago
Hi there,

nice catch! I've applied your patch changes are available in the trunk. I've 
deployed a new snapshot to the maven repository as well that contains the fix.
Thank you for your contribution!

cheers,

Roland

Original comment by ihatelivelyids on 15 Oct 2011 at 5:32