[CS2] Remove unnecessary utility helper functions (#4526)

* Uncomment module test that was waiting for classes to be supported

* Rely on native indexOf

* Replace `bind` helper with native `bind` (no shortcut necessary)

* Update output

* Update modules class tests

* Remove helper for prototype extends

* Update docs to reflect removed extends operator

* Add shortcut for splice, like we have for slice
This commit is contained in:
Geoffrey Booth
2017-04-25 07:10:42 -07:00
committed by GitHub
parent 7e35c2c3da
commit 07ae1edb44
12 changed files with 70 additions and 96 deletions

View File

@@ -433,47 +433,65 @@ test "export default predefined function", ->
export default foo;"""
eq toJS(input), output
# Uncomment this test once ES2015+ `class` support is added
test "export default class", ->
input = """
export default class foo extends bar
baz: ->
console.log 'hello, world!'"""
output = """
var foo;
# test "export default class", ->
# input = """
# export default class foo extends bar
# baz: ->
# console.log 'hello, world!'"""
# output = """
# export default class foo extends bar {
# baz: function {
# return console.log('hello, world!');
# }
# }"""
# eq toJS(input), output
export default foo = class foo extends bar {
baz() {
return console.log('hello, world!');
}
};"""
eq toJS(input), output
# Very limited tests for now, testing that `export class foo` either compiles
# identically (ES2015+) or at least into some function, leaving the specifics
# vague in case the CoffeeScript `class` interpretation changes
test "export class", ->
input = """
export class foo
baz: ->
console.log 'hello, world!'"""
output = toJS input
ok /^export (var foo = class foo|var foo = \(function)/.test toJS input
output = """
export var foo = class foo {
baz() {
return console.log('hello, world!');
}
};"""
eq toJS(input), output
test "export class that extends", ->
input = """
export class foo extends bar
baz: ->
console.log 'hello, world!'"""
output = toJS input
ok /export var foo = class foo/.test(output) and \
not /var foo(;|,)/.test output
output = """
export var foo = class foo extends bar {
baz() {
return console.log('hello, world!');
}
};"""
eq toJS(input), output
test "export default class that extends", ->
input = """
export default class foo extends bar
baz: ->
console.log 'hello, world!'"""
ok /export default foo = class foo/.test toJS input
output = """
var foo;
export default foo = class foo extends bar {
baz() {
return console.log('hello, world!');
}
};"""
eq toJS(input), output
test "export default named member, within an object", ->
input = "export { foo as default, bar }"