toolkit/devtools/sourcemap/tests/unit/test_dog_fooding.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/devtools/sourcemap/tests/unit/test_dog_fooding.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,80 @@
     1.4 +/*
     1.5 + * WARNING!
     1.6 + *
     1.7 + * Do not edit this file directly, it is built from the sources at
     1.8 + * https://github.com/mozilla/source-map/
     1.9 + */
    1.10 +
    1.11 +Components.utils.import('resource://test/Utils.jsm');
    1.12 +/* -*- Mode: js; js-indent-level: 2; -*- */
    1.13 +/*
    1.14 + * Copyright 2011 Mozilla Foundation and contributors
    1.15 + * Licensed under the New BSD license. See LICENSE or:
    1.16 + * http://opensource.org/licenses/BSD-3-Clause
    1.17 + */
    1.18 +define("test/source-map/test-dog-fooding", ["require", "exports", "module"], function (require, exports, module) {
    1.19 +
    1.20 +  var SourceMapConsumer = require('source-map/source-map-consumer').SourceMapConsumer;
    1.21 +  var SourceMapGenerator = require('source-map/source-map-generator').SourceMapGenerator;
    1.22 +
    1.23 +  exports['test eating our own dog food'] = function (assert, util) {
    1.24 +    var smg = new SourceMapGenerator({
    1.25 +      file: 'testing.js',
    1.26 +      sourceRoot: '/wu/tang'
    1.27 +    });
    1.28 +
    1.29 +    smg.addMapping({
    1.30 +      source: 'gza.coffee',
    1.31 +      original: { line: 1, column: 0 },
    1.32 +      generated: { line: 2, column: 2 }
    1.33 +    });
    1.34 +
    1.35 +    smg.addMapping({
    1.36 +      source: 'gza.coffee',
    1.37 +      original: { line: 2, column: 0 },
    1.38 +      generated: { line: 3, column: 2 }
    1.39 +    });
    1.40 +
    1.41 +    smg.addMapping({
    1.42 +      source: 'gza.coffee',
    1.43 +      original: { line: 3, column: 0 },
    1.44 +      generated: { line: 4, column: 2 }
    1.45 +    });
    1.46 +
    1.47 +    smg.addMapping({
    1.48 +      source: 'gza.coffee',
    1.49 +      original: { line: 4, column: 0 },
    1.50 +      generated: { line: 5, column: 2 }
    1.51 +    });
    1.52 +
    1.53 +    var smc = new SourceMapConsumer(smg.toString());
    1.54 +
    1.55 +    // Exact
    1.56 +    util.assertMapping(2, 2, '/wu/tang/gza.coffee', 1, 0, null, smc, assert);
    1.57 +    util.assertMapping(3, 2, '/wu/tang/gza.coffee', 2, 0, null, smc, assert);
    1.58 +    util.assertMapping(4, 2, '/wu/tang/gza.coffee', 3, 0, null, smc, assert);
    1.59 +    util.assertMapping(5, 2, '/wu/tang/gza.coffee', 4, 0, null, smc, assert);
    1.60 +
    1.61 +    // Fuzzy
    1.62 +
    1.63 +    // Original to generated
    1.64 +    util.assertMapping(2, 0, null, null, null, null, smc, assert, true);
    1.65 +    util.assertMapping(2, 9, '/wu/tang/gza.coffee', 1, 0, null, smc, assert, true);
    1.66 +    util.assertMapping(3, 0, '/wu/tang/gza.coffee', 1, 0, null, smc, assert, true);
    1.67 +    util.assertMapping(3, 9, '/wu/tang/gza.coffee', 2, 0, null, smc, assert, true);
    1.68 +    util.assertMapping(4, 0, '/wu/tang/gza.coffee', 2, 0, null, smc, assert, true);
    1.69 +    util.assertMapping(4, 9, '/wu/tang/gza.coffee', 3, 0, null, smc, assert, true);
    1.70 +    util.assertMapping(5, 0, '/wu/tang/gza.coffee', 3, 0, null, smc, assert, true);
    1.71 +    util.assertMapping(5, 9, '/wu/tang/gza.coffee', 4, 0, null, smc, assert, true);
    1.72 +
    1.73 +    // Generated to original
    1.74 +    util.assertMapping(2, 2, '/wu/tang/gza.coffee', 1, 1, null, smc, assert, null, true);
    1.75 +    util.assertMapping(3, 2, '/wu/tang/gza.coffee', 2, 3, null, smc, assert, null, true);
    1.76 +    util.assertMapping(4, 2, '/wu/tang/gza.coffee', 3, 6, null, smc, assert, null, true);
    1.77 +    util.assertMapping(5, 2, '/wu/tang/gza.coffee', 4, 9, null, smc, assert, null, true);
    1.78 +  };
    1.79 +
    1.80 +});
    1.81 +function run_test() {
    1.82 +  runSourceMapTests('test/source-map/test-dog-fooding', do_throw);
    1.83 +}

mercurial