@@ -12966,14 +12966,16 @@ def test_es5_transpile(self, args):
1296612966 # - arrow funcs
1296712967 # - for..of
1296812968 # - object.assign
12969+ # - nullish coalescing & chaining
12970+ # - logical assignment
1296912971 create_file('es6_library.js', '''\
1297012972 addToLibrary({
1297112973 foo: function(arg="hello") {
1297212974 // Object.assign + let
1297312975 let obj = Object.assign({}, {prop:1});
1297412976 err('prop: ' + obj.prop);
1297512977
12976- // arror funcs + const
12978+ // arrow funcs + const
1297712979 const bar = () => 2;
1297812980 err('bar: ' + bar());
1297912981
@@ -12990,6 +12992,22 @@ def test_es5_transpile(self, args):
1299012992 };
1299112993 global['foo'] = obj3;
1299212994 err('value2: ' + obj3.myMethod());
12995+
12996+ // Nullish coalescing
12997+ var definitely = global['maybe'] ?? {};
12998+
12999+ // Optional chaining
13000+ global['maybe']
13001+ ?.subObj
13002+ ?.[key]
13003+ ?.func
13004+ ?.();
13005+
13006+ // Logical assignment
13007+ var obj4 = null;
13008+ obj4 ??= 0;
13009+ obj4 ||= 1;
13010+ obj4 &&= 2;
1299313011 }
1299413012 });
1299513013 ''')
@@ -13004,13 +13022,22 @@ def check_for_es6(filename, expect):
1300413022 self.assertContained(['() => 2', '()=>2'], js)
1300513023 self.assertContained('const ', js)
1300613024 self.assertContained('let ', js)
13025+ self.assertContained('?.[', js)
13026+ self.assertContained('?.(', js)
13027+ self.assertContained('??=', js)
13028+ self.assertContained('||=', js)
13029+ self.assertContained('&&=', js)
1300713030 else:
1300813031 self.verify_es5(filename)
1300913032 self.assertNotContained('foo(arg=', js)
1301013033 self.assertNotContained('() => 2', js)
1301113034 self.assertNotContained('()=>2', js)
1301213035 self.assertNotContained('const ', js)
1301313036 self.assertNotContained('let ', js)
13037+ self.assertNotContained('??', js)
13038+ self.assertNotContained('?.', js)
13039+ self.assertNotContained('||=', js)
13040+ self.assertNotContained('&&=', js)
1301413041
1301513042 # Check that under normal circumstances none of these features get
1301613043 # removed / transpiled.
0 commit comments