@@ -12990,7 +12990,7 @@ def test_hello_function(self):
12990
12990
})
12991
12991
@crossplatform
12992
12992
def test_es5_transpile(self, args):
12993
- self.emcc_args += args
12993
+ self.emcc_args += ['-Wno-transpile'] + args
12994
12994
12995
12995
# Create a library file that uses the following ES6 features
12996
12996
# - let/const
@@ -13006,6 +13006,11 @@ def test_es5_transpile(self, args):
13006
13006
let obj = Object.assign({}, {prop:1});
13007
13007
err('prop: ' + obj.prop);
13008
13008
13009
+ // for .. of
13010
+ for (var elem of [42, 43]) {
13011
+ err('array elem: ' + elem);
13012
+ }
13013
+
13009
13014
// arrow funcs + const
13010
13015
const bar = () => 2;
13011
13016
err('bar: ' + bar());
@@ -13015,14 +13020,14 @@ def test_es5_transpile(self, args):
13015
13020
var obj2 = {
13016
13021
[key]: 42,
13017
13022
};
13018
- err('value : ' + obj2[key]);
13023
+ err('computed prop : ' + obj2[key]);
13019
13024
13020
13025
// Method syntax
13021
13026
var obj3 = {
13022
13027
myMethod() { return 43 },
13023
13028
};
13024
13029
global['foo'] = obj3;
13025
- err('value2 : ' + obj3.myMethod());
13030
+ err('myMethod : ' + obj3.myMethod());
13026
13031
13027
13032
// Nullish coalescing
13028
13033
var definitely = global['maybe'] ?? {};
@@ -13042,6 +13047,15 @@ def test_es5_transpile(self, args):
13042
13047
}
13043
13048
});
13044
13049
''')
13050
+ expected = '''\
13051
+ prop: 1
13052
+ array elem: 42
13053
+ array elem: 43
13054
+ bar: 2
13055
+ computed prop: 42
13056
+ myMethod: 43
13057
+ '''
13058
+
13045
13059
create_file('test.c', 'extern void foo(); int main() { foo(); }')
13046
13060
self.emcc_args += ['--js-library', 'es6_library.js']
13047
13061
self.uses_es6 = True
@@ -13073,26 +13087,26 @@ def check_for_es6(filename, expect):
13073
13087
# Check that under normal circumstances none of these features get
13074
13088
# removed / transpiled.
13075
13089
print('base case')
13076
- self.do_runf('test.c', 'prop: 1\nbar: 2\n' )
13090
+ self.do_runf('test.c', expected )
13077
13091
check_for_es6('test.js', True)
13078
13092
13079
13093
# If we select and older browser than closure will kick in by default
13080
13094
# to transpile.
13081
13095
print('with old browser')
13082
13096
self.emcc_args.remove('-Werror')
13083
13097
self.set_setting('MIN_CHROME_VERSION', '10')
13084
- self.do_runf('test.c', 'prop: 1\nbar: 2\n' , output_basename='test_old')
13098
+ self.do_runf('test.c', expected , output_basename='test_old')
13085
13099
check_for_es6('test_old.js', False)
13086
13100
13087
13101
# If we add `--closure=0` that transpiler (closure) is not run at all
13088
13102
print('with old browser + --closure=0')
13089
- self.do_runf('test.c', 'prop: 1\nbar: 2\n' , emcc_args=['--closure=0'], output_basename='test_no_closure')
13103
+ self.do_runf('test.c', expected , emcc_args=['--closure=0'], output_basename='test_no_closure')
13090
13104
check_for_es6('test_no_closure.js', True)
13091
13105
13092
13106
# If we use `--closure=1` closure will run in full optimization mode
13093
13107
# and also transpile to ES5
13094
13108
print('with old browser + --closure=1')
13095
- self.do_runf('test.c', 'prop: 1\nbar: 2\n' , emcc_args=['--closure=1'], output_basename='test_closure')
13109
+ self.do_runf('test.c', expected , emcc_args=['--closure=1'], output_basename='test_closure')
13096
13110
check_for_es6('test_closure.js', False)
13097
13111
13098
13112
def test_gmtime_noleak(self):
0 commit comments