summaryrefslogtreecommitdiffstats
path: root/third_party/webkit/PerformanceTests/six-speed/tests/object-assign.es5
blob: 33d1571d279aa8449fdf0eee60506535a98bab9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var obj = {
  a: 1,
  b: true,
  c: function () {},
  d: null,
  e: 'e'
};

var fn = function (src) {
  var o = {};
  var keys = Object.keys(src);
  for (var i = 0; i < keys.length; ++i) {
    var key = keys[i];
    o[key] = src[key];
  }
  return o;
};

var r = fn(obj);
assertEqual(r.a, obj.a);
assertEqual(r.b, obj.b);
assertEqual(r.c, obj.c);
assertEqual(r.d, obj.d);
assertEqual(r.e, obj.e);

test(function () {
  fn(obj);
});