test: add tests for boolean related comparison (#563)

This commit is contained in:
阿良仔 2023-07-17 20:55:42 +08:00 committed by GitHub
parent d410d1a2d7
commit 3cbec3459a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -232,6 +232,45 @@ fn test_null_comparison1() {
test_same("x==null");
}
#[test]
fn test_boolean_boolean_comparison() {
test_same("!x==!y");
test_same("!x<!y");
test_same("!x!==!y");
test_same("!x==!x"); // foldable
test_same("!x<!x"); // foldable
test_same("!x!==!x"); // foldable
}
#[test]
fn test_boolean_number_comparison() {
test_same("!x==+y");
test_same("!x<=+y");
test_wcb("!x !== +y", "true");
}
#[test]
fn test_number_boolean_comparison() {
test_same("+x==!y");
test_same("+x<=!y");
test_wcb("+x === !y", "false");
}
#[test]
fn test_boolean_string_comparison() {
test_same("!x==''+y");
test_same("!x<=''+y");
test_wcb("!x !== '' + y", "true");
}
#[test]
fn test_string_boolean_comparison() {
test_same("''+x==!y");
test_same("''+x<=!y");
test_wcb("'' + x === !y", "false");
}
#[test]
fn test_string_string_comparison() {
test("'a' < 'b'", "!0");