"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cli/ast/mod.rs" between
deno-1.12.0.tar.gz and deno-1.12.1.tar.gz

About: Deno is is a simple, modern and secure runtime for JavaScript and TypeScript that uses the V8 JavaScript engine and is built in Rust.

mod.rs  (deno-1.12.0):mod.rs  (deno-1.12.1)
skipping to change at line 262 skipping to change at line 262
.field("comments", &self.comments) .field("comments", &self.comments)
.field("leading_comments", &self.leading_comments) .field("leading_comments", &self.leading_comments)
.field("module", &self.module) .field("module", &self.module)
.finish() .finish()
} }
} }
impl ParsedModule { impl ParsedModule {
/// Return a vector of dependencies for the module. /// Return a vector of dependencies for the module.
pub fn analyze_dependencies(&self) -> Vec<DependencyDescriptor> { pub fn analyze_dependencies(&self) -> Vec<DependencyDescriptor> {
analyze_dependencies(&self.module, &self.source_map, &self.comments) analyze_dependencies(&self.module, &self.comments)
} }
/// Get the module's leading comments, where triple slash directives might /// Get the module's leading comments, where triple slash directives might
/// be located. /// be located.
pub fn get_leading_comments(&self) -> Vec<Comment> { pub fn get_leading_comments(&self) -> Vec<Comment> {
self.leading_comments.clone() self.leading_comments.clone()
} }
/// Get the module's comments. /// Get the module's comments.
pub fn get_comments(&self) -> Vec<Comment> { pub fn get_comments(&self) -> Vec<Comment> {
skipping to change at line 598 skipping to change at line 598
}), }),
}, },
]) ])
} }
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use std::collections::HashMap; use std::collections::HashMap;
use swc_common::BytePos;
use swc_ecmascript::dep_graph::DependencyKind; use swc_ecmascript::dep_graph::DependencyKind;
#[test] #[test]
fn test_parsed_module_analyze_dependencies() { fn test_parsed_module_analyze_dependencies() {
let specifier = resolve_url_or_path("https://deno.land/x/mod.js").unwrap(); let specifier = resolve_url_or_path("https://deno.land/x/mod.js").unwrap();
let source = r#"import * as bar from "./test.ts"; let source = "import * as bar from './test.ts';\nconst foo = await import('.
const foo = await import("./foo.ts"); /foo.ts');";
"#;
let parsed_module = let parsed_module =
parse(specifier.as_str(), source, &MediaType::JavaScript) parse(specifier.as_str(), source, &MediaType::JavaScript)
.expect("could not parse module"); .expect("could not parse module");
let actual = parsed_module.analyze_dependencies(); let actual = parsed_module.analyze_dependencies();
assert_eq!( assert_eq!(
actual, actual,
vec![ vec![
DependencyDescriptor { DependencyDescriptor {
kind: DependencyKind::Import, kind: DependencyKind::Import,
is_dynamic: false, is_dynamic: false,
leading_comments: Vec::new(), leading_comments: Vec::new(),
col: 0, span: Span::new(BytePos(0), BytePos(33), Default::default()),
line: 1,
specifier: "./test.ts".into(), specifier: "./test.ts".into(),
specifier_col: 21, specifier_span: Span::new(
specifier_line: 1, BytePos(21),
BytePos(32),
Default::default()
),
import_assertions: HashMap::default(), import_assertions: HashMap::default(),
}, },
DependencyDescriptor { DependencyDescriptor {
kind: DependencyKind::Import, kind: DependencyKind::Import,
is_dynamic: true, is_dynamic: true,
leading_comments: Vec::new(), leading_comments: Vec::new(),
col: 22, span: Span::new(BytePos(52), BytePos(70), Default::default()),
line: 2,
specifier: "./foo.ts".into(), specifier: "./foo.ts".into(),
specifier_col: 29, specifier_span: Span::new(
specifier_line: 2, BytePos(59),
BytePos(69),
Default::default()
),
import_assertions: HashMap::default(), import_assertions: HashMap::default(),
} }
] ]
); );
} }
#[test] #[test]
fn test_transpile() { fn test_transpile() {
let specifier = resolve_url_or_path("https://deno.land/x/mod.ts") let specifier = resolve_url_or_path("https://deno.land/x/mod.ts")
.expect("could not resolve specifier"); .expect("could not resolve specifier");
 End of changes. 7 change blocks. 
12 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)