Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / escodegen / node_modules / source-map / test / source-map / test-dog-fooding.js
1 /* -*- Mode: js; js-indent-level: 2; -*- */
2 /*
3  * Copyright 2011 Mozilla Foundation and contributors
4  * Licensed under the New BSD license. See LICENSE or:
5  * http://opensource.org/licenses/BSD-3-Clause
6  */
7 if (typeof define !== 'function') {
8     var define = require('amdefine')(module, require);
9 }
10 define(function (require, exports, module) {
11
12   var SourceMapConsumer = require('../../lib/source-map/source-map-consumer').SourceMapConsumer;
13   var SourceMapGenerator = require('../../lib/source-map/source-map-generator').SourceMapGenerator;
14
15   exports['test eating our own dog food'] = function (assert, util) {
16     var smg = new SourceMapGenerator({
17       file: 'testing.js',
18       sourceRoot: '/wu/tang'
19     });
20
21     smg.addMapping({
22       source: 'gza.coffee',
23       original: { line: 1, column: 0 },
24       generated: { line: 2, column: 2 }
25     });
26
27     smg.addMapping({
28       source: 'gza.coffee',
29       original: { line: 2, column: 0 },
30       generated: { line: 3, column: 2 }
31     });
32
33     smg.addMapping({
34       source: 'gza.coffee',
35       original: { line: 3, column: 0 },
36       generated: { line: 4, column: 2 }
37     });
38
39     smg.addMapping({
40       source: 'gza.coffee',
41       original: { line: 4, column: 0 },
42       generated: { line: 5, column: 2 }
43     });
44
45     smg.addMapping({
46       source: 'gza.coffee',
47       original: { line: 5, column: 10 },
48       generated: { line: 6, column: 12 }
49     });
50
51     var smc = new SourceMapConsumer(smg.toString());
52
53     // Exact
54     util.assertMapping(2, 2, '/wu/tang/gza.coffee', 1, 0, null, smc, assert);
55     util.assertMapping(3, 2, '/wu/tang/gza.coffee', 2, 0, null, smc, assert);
56     util.assertMapping(4, 2, '/wu/tang/gza.coffee', 3, 0, null, smc, assert);
57     util.assertMapping(5, 2, '/wu/tang/gza.coffee', 4, 0, null, smc, assert);
58     util.assertMapping(6, 12, '/wu/tang/gza.coffee', 5, 10, null, smc, assert);
59
60     // Fuzzy
61
62     // Generated to original
63     util.assertMapping(2, 0, null, null, null, null, smc, assert, true);
64     util.assertMapping(2, 9, '/wu/tang/gza.coffee', 1, 0, null, smc, assert, true);
65     util.assertMapping(3, 0, null, null, null, null, smc, assert, true);
66     util.assertMapping(3, 9, '/wu/tang/gza.coffee', 2, 0, null, smc, assert, true);
67     util.assertMapping(4, 0, null, null, null, null, smc, assert, true);
68     util.assertMapping(4, 9, '/wu/tang/gza.coffee', 3, 0, null, smc, assert, true);
69     util.assertMapping(5, 0, null, null, null, null, smc, assert, true);
70     util.assertMapping(5, 9, '/wu/tang/gza.coffee', 4, 0, null, smc, assert, true);
71     util.assertMapping(6, 0, null, null, null, null, smc, assert, true);
72     util.assertMapping(6, 9, null, null, null, null, smc, assert, true);
73     util.assertMapping(6, 13, '/wu/tang/gza.coffee', 5, 10, null, smc, assert, true);
74
75     // Original to generated
76     util.assertMapping(2, 2, '/wu/tang/gza.coffee', 1, 1, null, smc, assert, null, true);
77     util.assertMapping(3, 2, '/wu/tang/gza.coffee', 2, 3, null, smc, assert, null, true);
78     util.assertMapping(4, 2, '/wu/tang/gza.coffee', 3, 6, null, smc, assert, null, true);
79     util.assertMapping(5, 2, '/wu/tang/gza.coffee', 4, 9, null, smc, assert, null, true);
80     util.assertMapping(5, 2, '/wu/tang/gza.coffee', 5, 9, null, smc, assert, null, true);
81     util.assertMapping(6, 12, '/wu/tang/gza.coffee', 6, 19, null, smc, assert, null, true);
82   };
83
84 });