Skip to content

Commit

Permalink
Changed name of visitor functions for enums
Browse files Browse the repository at this point in the history
Also added a test for unssported Enums of 64 bits.
  • Loading branch information
Guillermo León authored and rajsite committed Jun 29, 2018
1 parent 50fdf2e commit 2be5809
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
12 changes: 6 additions & 6 deletions source/core/module_typeHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@
var fnName = '';
switch (sizeOfEnum) {
case 1:
visitFn = typeVisitor.visitEnumUInt8;
fnName = 'visitEnumUInt8';
visitFn = typeVisitor.visitEnum8;
fnName = 'visitEnum8';
break;
case 2:
visitFn = typeVisitor.visitEnumUInt16;
fnName = 'visitEnumUInt16';
visitFn = typeVisitor.visitEnum16;
fnName = 'visitEnum16';
break;
case 4:
visitFn = typeVisitor.visitEnumUInt32;
fnName = 'visitEnumUInt32';
visitFn = typeVisitor.visitEnum32;
fnName = 'visitEnum32';
break;
default:
throw new Error('Unexpected size for Enum. Found: ' + sizeOfEnum);
Expand Down
16 changes: 10 additions & 6 deletions test-it/karma/publicapi/TypeReflection.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ describe('The Vireo EggShell Reflection API', function () {

return {
visitBoolean: returnTypeName('Boolean'),
visitEnumUInt8: returnTypeName('Enum8'),
visitEnumUInt16: returnTypeName('Enum16'),
visitEnumUInt32: returnTypeName('Enum32'),
visitEnum8: returnTypeName('Enum8'),
visitEnum16: returnTypeName('Enum16'),
visitEnum32: returnTypeName('Enum32'),
visitInt8: returnTypeName('Int8'),
visitInt16: returnTypeName('Int16'),
visitInt32: returnTypeName('Int32'),
Expand Down Expand Up @@ -98,13 +98,17 @@ describe('The Vireo EggShell Reflection API', function () {
expect(reflectOnEmptyVisitor('dataItem_String')).toThrowError(/visitString/);
expect(reflectOnEmptyVisitor('dataItem_Boolean')).toThrowError(/visitBoolean/);
expect(reflectOnEmptyVisitor('dataItem_Timestamp')).toThrowError(/visitTimestamp/);
expect(reflectOnEmptyVisitor('enum8alphabet')).toThrowError(/visitEnumUInt8/);
expect(reflectOnEmptyVisitor('enum16numbers')).toThrowError(/visitEnumUInt16/);
expect(reflectOnEmptyVisitor('enum32colors')).toThrowError(/visitEnumUInt32/);
expect(reflectOnEmptyVisitor('enum8alphabet')).toThrowError(/visitEnum8/);
expect(reflectOnEmptyVisitor('enum16numbers')).toThrowError(/visitEnum16/);
expect(reflectOnEmptyVisitor('enum32colors')).toThrowError(/visitEnum32/);
expect(reflectOnEmptyVisitor('wave_Double')).toThrowError(/visitAnalogWaveform/);
expect(reflectOnEmptyVisitor('dataItem_ClusterOfScalars')).toThrowError(/visitCluster/);
expect(reflectOnEmptyVisitor('dataItem_ArrayOfBoolean')).toThrowError(/visitArray/);
});

it('throws for unsupported enum types', function () {
expect(reflectOnEmptyVisitor('enum64releases')).toThrowError(/Unexpected size/);
});
});

describe('dispatches a call on visitor', function () {
Expand Down

0 comments on commit 2be5809

Please sign in to comment.