Skip to content

Commit

Permalink
fix: Accept filenames that start with ./.. as modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Jan 11, 2020
1 parent 9bbf452 commit 01e450b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 16 additions & 1 deletion base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ pub fn filename_to_module(filename: &str) -> String {
.unwrap_or(filename)
});

name.replace(|c: char| c == '/' || c == '\\', ".")
name.trim_start_matches(|c: char| c == '.' || c == '/')
.replace(|c: char| c == '/' || c == '\\', ".")
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -153,3 +154,17 @@ impl fmt::Display for DebugLevel {
)
}
}

#[cfg(test)]
mod tests {

use super::*;

#[test]
fn filename_to_module_test() {
assert_eq!(filename_to_module("./main.glu"), "main");
assert_eq!(filename_to_module("main.glu"), "main");
assert_eq!(filename_to_module("./main/test.glu"), "main.test");
assert_eq!(filename_to_module("main/test.glu"), "main.test");
}
}
1 change: 0 additions & 1 deletion base/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ impl<T> AliasRemover<T> {
Some((typ, args)) => match *typ {
Type::Builtin(..)
| Type::Function(..)
| Type::Function(..)
| Type::Record(..)
| Type::Variant(..)
| Type::Effect(..)
Expand Down

0 comments on commit 01e450b

Please sign in to comment.