Skip to content

Commit

Permalink
Test JS generation for Flow types
Browse files Browse the repository at this point in the history
Reviewed By: tmikov

Differential Revision: D31084336

fbshipit-source-id: 14dd3d20648b938a26abdab288bfdc806a3f5cd7
  • Loading branch information
avp authored and facebook-github-bot committed Sep 23, 2021
1 parent 4359935 commit 0704278
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions unsupported/juno/tests/gen_js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ fn test_roundtrip(src1: &str) {
test_roundtrip_with_flags(Default::default(), src1)
}

fn test_roundtrip_flow(src1: &str) {
test_roundtrip_with_flags(
hparser::ParserFlags {
strict_mode: false,
enable_jsx: false,
dialect: hparser::ParserDialect::Flow,
},
src1,
);
}

#[test]
fn test_literals() {
use NodeKind::*;
Expand Down Expand Up @@ -420,4 +431,18 @@ fn test_types() {
do_gen(&ctx, union_ty, gen_js::Pretty::Yes).trim(),
"number | boolean & string"
);

test_roundtrip_flow("type A = number");
test_roundtrip_flow("type A = ?number");
test_roundtrip_flow("type A = string");
test_roundtrip_flow("type A = 'foo'");
test_roundtrip_flow("type A = 3");
test_roundtrip_flow("type A = boolean");
test_roundtrip_flow("type A = true | false");
test_roundtrip_flow("type A = symbol");
test_roundtrip_flow("type A = mixed");
test_roundtrip_flow("type A = any");
test_roundtrip_flow("type A = void");
test_roundtrip_flow("type A = number => number");
test_roundtrip_flow("type A = (number, string) => number");
}

0 comments on commit 0704278

Please sign in to comment.