Skip to content

Commit

Permalink
Rust tests for var x and let x default to undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
pop committed Oct 3, 2019
1 parent 022fb02 commit 95827a4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
.idea/
*.iml

# Vim
.*.swp
.*.swo

# Build
target
dist
**/*.rs.bk
node_modules
.DS_Store
yarn-error.log
.vscode/settings.json
.vscode/settings.json
29 changes: 29 additions & 0 deletions src/lib/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,3 +630,32 @@ impl Interpreter {
}
}
}

#[cfg(test)]
mod tests {
use crate::exec;

#[test]
fn empty_let_decl_undefined() {
let scenario = r#"
let a;
a == undefined;
"#;

let pass = String::from("true");

assert_eq!(exec(scenario), pass);
}

#[test]
fn empty_var_decl_undefined() {
let scenario = r#"
let b;
b == undefined;
"#;

let pass = String::from("true");

assert_eq!(exec(scenario), pass);
}
}

0 comments on commit 95827a4

Please sign in to comment.