Skip to content

Commit

Permalink
add more testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Dec 17, 2021
1 parent f34c8e2 commit 08645c4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
10 changes: 5 additions & 5 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ See docs/process.md for more on how version tagging works.

3.0.1
-----
- Emscripten in starting to use ES6 features in its core libraries (at last!).
For most user targeting the default set of browser this is a code size win.
For projects targeting older browsers (e.g. `-sMIN_CHROME_VERSION=10`)
emscripten will now run closure compiler `WHITESPACE_ONLY` in order to
- Emscripten is starting to use ES6 features in its core libraries (at last!).
For most user targeting the default set of browsers this is a code size win.
For projects targeting older browsers (e.g. `-sMIN_CHROME_VERSION=10`),
emscripten will now run closure compiler in `WHITESPACE_ONLY` mode in order to
traspile any ES6 down to ES5. When this automatic transpilation is performed
we generate a warning which can disabled by either opting explicitly in-to or
out-of closure usage using `--closure=1` or `--closure=0`. (#15763).
out-of closure using `--closure=1` or `--closure=0`. (#15763).
- Deprecate `EMMAKEN_CFLAGS` is favor of `EMCC_CFLAGS`.
- Fixed an issue where user provided --js-library directives would not be
processed as the last item after all system provided JS libraries have been
Expand Down
2 changes: 1 addition & 1 deletion emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ def default_setting(name, new_default):
settings.TRANSPILE_TO_ES5 = (settings.MIN_EDGE_VERSION < 12 or
settings.MIN_FIREFOX_VERSION < 44 or
settings.MIN_CHROME_VERSION < 49 or
settings.MIN_SAFARI_VERSION < 11000 or
settings.MIN_SAFARI_VERSION < 110000 or
settings.MIN_IE_VERSION != 0x7FFFFFFF)

if options.use_closure_compiler is None and settings.TRANSPILE_TO_ES5:
Expand Down
2 changes: 1 addition & 1 deletion src/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var Module = typeof {{{ EXPORT_NAME }}} !== 'undefined' ? {{{ EXPORT_NAME }}} :
// See https://caniuse.com/mdn-javascript_builtins_object_assign
#if MIN_CHROME_VERSION < 45 || MIN_EDGE_VERSION < 12 || MIN_FIREFOX_VERSION < 34 || MIN_IE_VERSION != TARGET_NOT_SUPPORTED || MIN_SAFARI_VERSION < 90000
function objAssign(target, source) {
for (key in source) {
for (var key in source) {
if (source.hasOwnProperty(key)) {
target[key] = source[key];
}
Expand Down
20 changes: 18 additions & 2 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -11317,7 +11317,13 @@ def test_hello_function(self):
# as `examples/`?)
self.run_process([EMCC, test_file('hello_function.cpp'), '-o', 'function.html', '-sEXPORTED_FUNCTIONS=_int_sqrt', '-sEXPORTED_RUNTIME_METHODS=ccall,cwrap'])

def test_es5_transpile(self):
@parameterized({
'': ([],),
'O2': (['-O2'],),
})
def test_es5_transpile(self, args):
self.emcc_args += args

# Create a library file that uses the following ES6 features
# - let/const
# - arrow funcs
Expand All @@ -11343,26 +11349,36 @@ def test_es5_transpile(self):
def check_for_es6(expect):
js = read_file('test.js')
if expect:
self.assertContained('() => 2', js)
self.assertContained(['() => 2', '()=>2'], js)
self.assertContained('const ', js)
self.assertContained('let ', js)
else:
self.assertNotContained('() => 2', js)
self.assertNotContained('()=>2', js)
self.assertNotContained('const ', js)
self.assertNotContained('let ', js)

# Check that under normal circumstances none of these features get
# removed / transpiled.
print('base case')
self.do_runf('test.c', 'prop: 1\nbar: 2\n')
check_for_es6(True)

# If we select and older browser than closure will kick in by default
# to traspile.
print('with old browser')
self.emcc_args.remove('-Werror')
self.set_setting('MIN_CHROME_VERSION', '10')
self.do_runf('test.c', 'prop: 1\nbar: 2\n')
check_for_es6(False)

# If we add `--closure=0` that traspiler (closure) is not run at all
print('with old browser + --closure=0')
self.do_runf('test.c', 'prop: 1\nbar: 2\n', emcc_args=['--closure=0'])
check_for_es6(True)

# If we use `--closure=1` closure will run in full optimization mode
# and also transpile to ES5
print('with old browser + --closure=1')
self.do_runf('test.c', 'prop: 1\nbar: 2\n', emcc_args=['--closure=1'])
check_for_es6(False)

0 comments on commit 08645c4

Please sign in to comment.