You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All enum values of a given enum type generated by embind are considered equivalent by jasmine. Jasmine does object equality by doing a deep equals on most objects; however, this relies on being able to iterate over the object keys (using Object.keys). embind enum values are all objects with a single non-enumerable property with the underlying value. Since the value property isn't enumerable the object looks the same. For single values this is somewhat ok because the toBe matcher can be used instead; however, it becomes problematic when comparing the quality of objects/arrays using toEquals because the same logic is applied recursively.
I was wondering why emscripten didn't emit a simply dictionary of names and values for the enum like the following. It would mean you loose types for the enum, but would grant more direct access to the numeric values. This could also be typed cleanly in typescript typings (basically just declared as a normal typescript enum.
Version of emscripten/emsdk:
3.1.35
All enum values of a given enum type generated by embind are considered equivalent by jasmine. Jasmine does object equality by doing a deep equals on most objects; however, this relies on being able to iterate over the object keys (using
Object.keys
). embind enum values are all objects with a single non-enumerable property with the underlying value. Since thevalue
property isn't enumerable the object looks the same. For single values this is somewhat ok because thetoBe
matcher can be used instead; however, it becomes problematic when comparing the quality of objects/arrays usingtoEquals
because the same logic is applied recursively.For example
The setup code simplifies to roughly something like the following:
One option to fix this could be to simply make the
value
property enumerable, but not sure if that would be a breaking change.The text was updated successfully, but these errors were encountered: