1 /* -*- Mode: js; js-indent-level: 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
7 if (typeof define !== 'function') {
8 var define = require('amdefine')(module, require);
10 define(function (require, exports, module) {
12 var SourceMapConsumer = require('../../lib/source-map/source-map-consumer').SourceMapConsumer;
13 var SourceMapGenerator = require('../../lib/source-map/source-map-generator').SourceMapGenerator;
15 exports['test eating our own dog food'] = function (assert, util) {
16 var smg = new SourceMapGenerator({
18 sourceRoot: '/wu/tang'
23 original: { line: 1, column: 0 },
24 generated: { line: 2, column: 2 }
29 original: { line: 2, column: 0 },
30 generated: { line: 3, column: 2 }
35 original: { line: 3, column: 0 },
36 generated: { line: 4, column: 2 }
41 original: { line: 4, column: 0 },
42 generated: { line: 5, column: 2 }
47 original: { line: 5, column: 10 },
48 generated: { line: 6, column: 12 }
51 var smc = new SourceMapConsumer(smg.toString());
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);
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);
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);