This repository was archived by the owner on Feb 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Support enums #31
Merged
Merged
Support enums #31
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/// <reference path="../typings/chai/chai.d.ts"/> | ||
/// <reference path="../typings/mocha/mocha.d.ts"/> | ||
/// <reference path="../typings/source-map-support/source-map-support.d.ts"/> | ||
|
||
import sms = require('source-map-support'); | ||
|
@@ -107,6 +108,24 @@ describe('transpile to dart', () => { | |
}); | ||
}); | ||
|
||
describe('enums', () => { | ||
it('should support basic enum declaration', () => { | ||
expectTranslate('enum Color { Red, Green, Blue }') | ||
.to.equal(' enum Color { Red , Green , Blue }'); | ||
}); | ||
it('does not support empty enum', () => { | ||
chai.expect(() => translateSource('enum Empty { }')) | ||
.to.throw('empty enums are not supported'); | ||
}); | ||
it('does not support enum with initializer', () => { | ||
chai.expect(() => translateSource('enum Color { Red = 1, Green, Blue = 4 }')) | ||
.to.throw('enum initializers are not supported'); | ||
}); | ||
it('should support switch over enum', () => { | ||
expectTranslate('switch(c) { case Color.Red: break; default: break; }') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for my information, this is not different in any kind from a plain switch over anything else, is it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. (This test just made me feel better that a case label could be written as, e.g., |
||
.to.equal(' switch ( c ) { case Color . Red : break ; default : break ; }'); | ||
}); | ||
}); | ||
|
||
describe('functions', () => { | ||
it('supports declarations', | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test for const enums?
microsoft/TypeScript#1029
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we address that in a separate issue / PR? Support or not of
const enum
s is IMHO debatable (in particular since there is no equivalent feature in Dart.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I'm also good with just failing for const enums for the time being.