From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

#! perl
##
# 000-basic.t - test basic sourcemap functionality
##
# Copyright (C) 2017 by attila <attila@stalphonsos.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
# PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
use strict;
use Test::More tests => 3;
use JS::SourceMap qw/discover loads/;
use t::lib;
our @discover = (
"
hey
this is some code
it's really awesome
//@ sourceMappingURL=file.js
",
"
hey
this is some code
it's really awesome
//# sourceMappingURL=file.js
",
"
there
is no sourcemap
here
");
is(discover($discover[0]),"file.js","discover 1");
is(discover($discover[1]),"file.js","discover 2");
is(discover($discover[2]),undef,"discover 3");
##
# Local variables:
# mode: perl
# tab-width: 8
# perl-indent-level: 8
# perl-continued-statement-offset: 4
# indent-tabs-mode: t
# End:
##