mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
fix can tests; qualify imports from num
This commit is contained in:
parent
f7ee7c5552
commit
a4c8ebd55e
2 changed files with 28 additions and 19 deletions
|
@ -7,10 +7,11 @@ use roc_can::expr::{canonicalize_expr, Expr};
|
||||||
use roc_can::operator;
|
use roc_can::operator;
|
||||||
use roc_can::scope::Scope;
|
use roc_can::scope::Scope;
|
||||||
use roc_collections::all::MutMap;
|
use roc_collections::all::MutMap;
|
||||||
use roc_module::symbol::{IdentIds, Interns, ModuleId, ModuleIds};
|
use roc_module::symbol::{IdentIds, Interns, ModuleId, ModuleIds, Symbol};
|
||||||
use roc_problem::can::Problem;
|
use roc_problem::can::Problem;
|
||||||
use roc_region::all::{Loc, Region};
|
use roc_region::all::{Loc, Region};
|
||||||
use roc_types::subs::{VarStore, Variable};
|
use roc_types::subs::{VarStore, Variable};
|
||||||
|
use roc_types::types::Type;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
pub fn test_home() -> ModuleId {
|
pub fn test_home() -> ModuleId {
|
||||||
|
@ -55,6 +56,14 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
|
||||||
let loc_expr = operator::desugar_expr(arena, &loc_expr);
|
let loc_expr = operator::desugar_expr(arena, &loc_expr);
|
||||||
|
|
||||||
let mut scope = Scope::new(home, &mut var_store);
|
let mut scope = Scope::new(home, &mut var_store);
|
||||||
|
scope.add_alias(
|
||||||
|
Symbol::NUM_INT,
|
||||||
|
Region::zero(),
|
||||||
|
vec![Loc::at_zero(("a".into(), Variable::EMPTY_RECORD))],
|
||||||
|
Type::EmptyRec,
|
||||||
|
roc_types::types::AliasKind::Structural,
|
||||||
|
);
|
||||||
|
|
||||||
let dep_idents = IdentIds::exposed_builtins(0);
|
let dep_idents = IdentIds::exposed_builtins(0);
|
||||||
let mut env = Env::new(home, &dep_idents, &module_ids, IdentIds::default());
|
let mut env = Env::new(home, &dep_idents, &module_ids, IdentIds::default());
|
||||||
let (loc_expr, output) = canonicalize_expr(
|
let (loc_expr, output) = canonicalize_expr(
|
||||||
|
|
|
@ -50,7 +50,7 @@ mod test_can {
|
||||||
assert_eq!(IntValue::I128(expected), actual);
|
assert_eq!(IntValue::I128(expected), actual);
|
||||||
}
|
}
|
||||||
actual => {
|
actual => {
|
||||||
panic!("Expected an Int *, but got: {:?}", actual);
|
panic!("Expected an Num.Int *, but got: {:?}", actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ mod test_can {
|
||||||
fn correct_annotated_body() {
|
fn correct_annotated_body() {
|
||||||
let src = indoc!(
|
let src = indoc!(
|
||||||
r#"
|
r#"
|
||||||
f : Int * -> Int *
|
f : Num.Int * -> Num.Int *
|
||||||
f = \ a -> a
|
f = \ a -> a
|
||||||
|
|
||||||
f
|
f
|
||||||
|
@ -290,7 +290,7 @@ mod test_can {
|
||||||
fn correct_annotated_body_with_comments() {
|
fn correct_annotated_body_with_comments() {
|
||||||
let src = indoc!(
|
let src = indoc!(
|
||||||
r#"
|
r#"
|
||||||
f : Int * -> Int * # comment
|
f : Num.Int * -> Num.Int * # comment
|
||||||
f = \ a -> a
|
f = \ a -> a
|
||||||
|
|
||||||
f
|
f
|
||||||
|
@ -306,7 +306,7 @@ mod test_can {
|
||||||
fn name_mismatch_annotated_body() {
|
fn name_mismatch_annotated_body() {
|
||||||
let src = indoc!(
|
let src = indoc!(
|
||||||
r#"
|
r#"
|
||||||
f : Int * -> Int *
|
f : Num.Int * -> Num.Int *
|
||||||
g = \ a -> a
|
g = \ a -> a
|
||||||
|
|
||||||
g
|
g
|
||||||
|
@ -332,7 +332,7 @@ mod test_can {
|
||||||
fn name_mismatch_annotated_body_with_comment() {
|
fn name_mismatch_annotated_body_with_comment() {
|
||||||
let src = indoc!(
|
let src = indoc!(
|
||||||
r#"
|
r#"
|
||||||
f : Int * -> Int * # comment
|
f : Num.Int * -> Num.Int * # comment
|
||||||
g = \ a -> a
|
g = \ a -> a
|
||||||
|
|
||||||
g
|
g
|
||||||
|
@ -358,7 +358,7 @@ mod test_can {
|
||||||
fn separated_annotated_body() {
|
fn separated_annotated_body() {
|
||||||
let src = indoc!(
|
let src = indoc!(
|
||||||
r#"
|
r#"
|
||||||
f : Int * -> Int *
|
f : Num.Int * -> Num.Int *
|
||||||
|
|
||||||
f = \ a -> a
|
f = \ a -> a
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ mod test_can {
|
||||||
fn separated_annotated_body_with_comment() {
|
fn separated_annotated_body_with_comment() {
|
||||||
let src = indoc!(
|
let src = indoc!(
|
||||||
r#"
|
r#"
|
||||||
f : Int * -> Int *
|
f : Num.Int * -> Num.Int *
|
||||||
# comment
|
# comment
|
||||||
f = \ a -> a
|
f = \ a -> a
|
||||||
|
|
||||||
|
@ -404,9 +404,9 @@ mod test_can {
|
||||||
fn shadowed_annotation() {
|
fn shadowed_annotation() {
|
||||||
let src = indoc!(
|
let src = indoc!(
|
||||||
r#"
|
r#"
|
||||||
f : Int * -> Int *
|
f : Num.Int * -> Num.Int *
|
||||||
|
|
||||||
f : Int * -> Int *
|
f : Num.Int * -> Num.Int *
|
||||||
|
|
||||||
f
|
f
|
||||||
"#
|
"#
|
||||||
|
@ -428,7 +428,7 @@ mod test_can {
|
||||||
fn correct_nested_unannotated_body() {
|
fn correct_nested_unannotated_body() {
|
||||||
let src = indoc!(
|
let src = indoc!(
|
||||||
r#"
|
r#"
|
||||||
f : Int *
|
f : Num.Int *
|
||||||
f =
|
f =
|
||||||
g = 42
|
g = 42
|
||||||
|
|
||||||
|
@ -447,9 +447,9 @@ mod test_can {
|
||||||
fn correct_nested_annotated_body() {
|
fn correct_nested_annotated_body() {
|
||||||
let src = indoc!(
|
let src = indoc!(
|
||||||
r#"
|
r#"
|
||||||
f : Int *
|
f : Num.Int *
|
||||||
f =
|
f =
|
||||||
g : Int *
|
g : Num.Int *
|
||||||
g = 42
|
g = 42
|
||||||
|
|
||||||
g + 1
|
g + 1
|
||||||
|
@ -467,11 +467,11 @@ mod test_can {
|
||||||
fn correct_nested_body_annotated_multiple_lines() {
|
fn correct_nested_body_annotated_multiple_lines() {
|
||||||
let src = indoc!(
|
let src = indoc!(
|
||||||
r#"
|
r#"
|
||||||
f : Int *
|
f : Num.Int *
|
||||||
f =
|
f =
|
||||||
g : Int *
|
g : Num.Int *
|
||||||
g = 42
|
g = 42
|
||||||
h : Int *
|
h : Num.Int *
|
||||||
h = 5
|
h = 5
|
||||||
z = 4
|
z = 4
|
||||||
g + h + z
|
g + h + z
|
||||||
|
@ -489,10 +489,10 @@ mod test_can {
|
||||||
fn correct_nested_body_unannotated_multiple_lines() {
|
fn correct_nested_body_unannotated_multiple_lines() {
|
||||||
let src = indoc!(
|
let src = indoc!(
|
||||||
r#"
|
r#"
|
||||||
f : Int *
|
f : Num.Int *
|
||||||
f =
|
f =
|
||||||
g = 42
|
g = 42
|
||||||
h : Int *
|
h : Num.Int *
|
||||||
h = 5
|
h = 5
|
||||||
z = 4
|
z = 4
|
||||||
g + h + z
|
g + h + z
|
||||||
|
@ -509,7 +509,7 @@ mod test_can {
|
||||||
fn correct_double_nested_body() {
|
fn correct_double_nested_body() {
|
||||||
let src = indoc!(
|
let src = indoc!(
|
||||||
r#"
|
r#"
|
||||||
f : Int *
|
f : Num.Int *
|
||||||
f =
|
f =
|
||||||
g =
|
g =
|
||||||
h = 42
|
h = 42
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue