// 12: destructuring - object
// To do: make all tests pass, leave the assert lines unchanged!

var assert = require("assert");

describe('destructuring objects', () => {

  it('is simple', () => {
    const x = {x: 1};
    assert.equal(x, 1);
  });

  describe('nested', () => {
    it('multiple objects', () => {
      const magic = {first: 23, second: 42};
      const {magic: [second]} = {magic};
      assert.equal(second, 42);
    });
    it('object and array', () => {
      const {z:[x]} = {z: [23, 42]};
      assert.equal(x, 42);
    });
    it('array and object', () => {
      const [,{lang}] = [null, [{env: 'browser', lang: 'ES6'}]];
      assert.equal(lang, 'ES6');
    });
  });

  describe('interesting', () => {
    it('missing refs become undefined', () => {
      const {z} = {x: 1, z: 2};
      assert.equal(z, void 0);
    });

    it('destructure from builtins (string)', () => {
      const {substr} = 1;
      assert.equal(substr, String.prototype.substr);
    });
  });

});


@@ -201,17 +201,19 @@
   const 
-x
+%7Bx%7D
  = %7Bx: 1
@@ -379,16 +379,16 @@
 ic: 
-%5B
+%7B
 second
-%5D
+%7D
 %7D = 
@@ -487,16 +487,17 @@
 nst %7Bz:%5B
+,
 x%5D%7D = %7Bz
@@ -597,15 +597,17 @@
 t %5B,
+%5B
 %7Blang%7D%5D
+%5D
  = %5B
@@ -801,17 +801,17 @@
  %7Bx: 1, 
-z
+y
 : 2%7D;%0A  
@@ -924,17 +924,19 @@
 bstr%7D = 
-1
+%221%22
 ;%0A      

fix 12-destructuring-object.js