@@ -12945,14 +12945,16 @@ def test_es5_transpile(self, args):
1294512945 # - arrow funcs
1294612946 # - for..of
1294712947 # - object.assign
12948+ # - nullish coalescing & chaining
12949+ # - logical assignment
1294812950 create_file('es6_library.js', '''\
1294912951 addToLibrary({
1295012952 foo: function(arg="hello") {
1295112953 // Object.assign + let
1295212954 let obj = Object.assign({}, {prop:1});
1295312955 err('prop: ' + obj.prop);
1295412956
12955- // arror funcs + const
12957+ // arrow funcs + const
1295612958 const bar = () => 2;
1295712959 err('bar: ' + bar());
1295812960
@@ -12969,6 +12971,22 @@ def test_es5_transpile(self, args):
1296912971 };
1297012972 global['foo'] = obj3;
1297112973 err('value2: ' + obj3.myMethod());
12974+
12975+ // Nullish coalescing
12976+ var definitely = global['maybe'] ?? {};
12977+
12978+ // Optional chaining
12979+ global['maybe']
12980+ ?.subObj
12981+ ?.[key]
12982+ ?.func
12983+ ?.();
12984+
12985+ // Logical assignment
12986+ var obj4 = null;
12987+ obj4 ??= 0;
12988+ obj4 ||= 1;
12989+ obj4 &&= 2;
1297212990 }
1297312991 });
1297412992 ''')
@@ -12983,13 +13001,22 @@ def check_for_es6(filename, expect):
1298313001 self.assertContained(['() => 2', '()=>2'], js)
1298413002 self.assertContained('const ', js)
1298513003 self.assertContained('let ', js)
13004+ self.assertContained('?.[', js)
13005+ self.assertContained('?.(', js)
13006+ self.assertContained('??=', js)
13007+ self.assertContained('||=', js)
13008+ self.assertContained('&&=', js)
1298613009 else:
1298713010 self.verify_es5(filename)
1298813011 self.assertNotContained('foo(arg=', js)
1298913012 self.assertNotContained('() => 2', js)
1299013013 self.assertNotContained('()=>2', js)
1299113014 self.assertNotContained('const ', js)
1299213015 self.assertNotContained('let ', js)
13016+ self.assertNotContained('??', js)
13017+ self.assertNotContained('?.', js)
13018+ self.assertNotContained('||=', js)
13019+ self.assertNotContained('&&=', js)
1299313020
1299413021 # Check that under normal circumstances none of these features get
1299513022 # removed / transpiled.
0 commit comments