main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
487 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var traverse = require('../');
|
---|
| 4 | var test = require('tape');
|
---|
| 5 |
|
---|
| 6 | test('negative update test', function (t) {
|
---|
| 7 | var obj = [5, 6, -3, [7, 8, -2, 1], { f: 10, g: -13 }];
|
---|
| 8 | var fixed = traverse.map(obj, function (x) {
|
---|
| 9 | if (x < 0) { this.update(x + 128); }
|
---|
| 10 | });
|
---|
| 11 |
|
---|
| 12 | t.same(
|
---|
| 13 | fixed,
|
---|
| 14 | [5, 6, 125, [7, 8, 126, 1], { f: 10, g: 115 }],
|
---|
| 15 | 'Negative values += 128'
|
---|
| 16 | );
|
---|
| 17 |
|
---|
| 18 | t.same(
|
---|
| 19 | obj,
|
---|
| 20 | [5, 6, -3, [7, 8, -2, 1], { f: 10, g: -13 }],
|
---|
| 21 | 'Original references not modified'
|
---|
| 22 | );
|
---|
| 23 |
|
---|
| 24 | t.end();
|
---|
| 25 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.