repo stringlengths 6 65 | file_url stringlengths 81 311 | file_path stringlengths 6 227 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:31:58 2026-01-04 20:25:31 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/type_/tests/target_implementations.rs | compiler-core/src/type_/tests/target_implementations.rs | use ecow::EcoString;
use itertools::Itertools;
use crate::{
analyse::TargetSupport, assert_module_error, build::Target, type_::expression::Implementations,
};
use super::compile_module_with_opts;
macro_rules! assert_targets {
($src:expr, $implementations:expr $(,)?) => {
let result = $crate::type_::t... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/type_/tests/type_alias.rs | compiler-core/src/type_/tests/type_alias.rs | use crate::{assert_module_error, assert_module_infer};
#[test]
fn alias_dep() {
assert_module_infer!(
r#"
type E = #(F, C)
type F = fn(CustomA) -> CustomB(B)
type A = Int
type B = C
type C = CustomA
type D = CustomB(C)
type CustomA {
CustomA()
}
type CustomB(a) {
CustomB(a)
}
"#,
vec![],
)... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/type_/tests/pretty.rs | compiler-core/src/type_/tests/pretty.rs | use std::sync::Arc;
use crate::type_::{
Type,
prelude::{bool, int, tuple},
pretty::Printer,
};
use super::Publicity;
fn print(type_: Arc<Type>) -> String {
Printer::new().pretty_print(&type_, 0)
}
fn custom_bool() -> Arc<Type> {
Arc::new(Type::Named {
publicity: Publicity::Public,
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/type_/tests/warnings.rs | compiler-core/src/type_/tests/warnings.rs | use super::*;
use crate::{
assert_js_no_warnings, assert_js_warning, assert_no_warnings, assert_warning,
assert_warnings_with_gleam_version,
};
#[test]
fn unknown_label() {
// https://github.com/gleam-lang/gleam/issues/1098
// calling function with unused labelled argument should not emit warnings
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | true |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/config/stale_package_remover.rs | compiler-core/src/config/stale_package_remover.rs | use crate::manifest::Manifest;
use crate::requirement::Requirement;
use ecow::EcoString;
use hexpm::version::Version;
use std::collections::{HashMap, HashSet};
#[derive(Debug)]
pub struct StalePackageRemover<'a> {
// These are the packages for which the requirement or their parents
// requirement has not chang... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests.rs | compiler-core/src/format/tests.rs | use pretty_assertions::assert_eq;
mod asignments;
mod binary_operators;
mod bit_array;
mod blocks;
mod cases;
mod conditional_compilation;
mod constant;
mod custom_type;
mod echo;
mod external_fn;
mod external_types;
mod function;
mod guards;
mod imports;
mod lists;
mod pipeline;
mod record_update;
mod tuple;
mod use_... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | true |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/external_fn.rs | compiler-core/src/format/tests/external_fn.rs | use crate::assert_format;
#[test]
fn no_body_erlang() {
assert_format!(
r#"@external(erlang, "one", "one")
fn one(x: Int) -> Int
"#
);
}
#[test]
fn no_body_javascript() {
assert_format!(
r#"@external(javascript, "one", "one")
fn one(x: Int) -> Int
"#
);
}
#[test]
fn no_body_body() {
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/use_.rs | compiler-core/src/format/tests/use_.rs | use crate::{assert_format, assert_format_rewrite};
#[test]
fn use_1() {
assert_format!(
r#"pub fn main() {
use <- benchmark("thingy")
todo
}
"#
);
}
#[test]
fn use_2() {
assert_format!(
r#"pub fn main() {
use user <- login()
todo
}
"#
);
}
#[test]
fn use_3() {
assert_forma... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/imports.rs | compiler-core/src/format/tests/imports.rs | use crate::{assert_format, assert_format_rewrite};
#[test]
fn types_and_values() {
assert_format!(
"import one/two.{type Abc, type Bcd, Abc, Bcd, abc, bcd}
"
);
}
#[test]
fn discarded_import() {
assert_format!(
"import one/two as _three
"
);
}
#[test]
fn discarded_import_with_unqualif... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/guards.rs | compiler-core/src/format/tests/guards.rs | use crate::assert_format;
#[test]
fn field_access() {
assert_format!(
r#"pub fn main() {
case x {
_ if a.b -> 1
_ -> 0
}
}
"#
);
}
#[test]
fn nested_field_access() {
assert_format!(
r#"pub fn main() {
case x {
_ if a.b.c.d -> 1
_ -> 0
}
}
"#
);
}
#[test]
fn ope... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/custom_type.rs | compiler-core/src/format/tests/custom_type.rs | use crate::assert_format;
#[test]
fn custom_type_0() {
assert_format!(
"type WowThisTypeHasJustTheLongestName(
some_long_type_variable,
and_another,
and_another_again,
) {
Make
}
"
);
}
#[test]
fn custom_type_1() {
assert_format!(
"type Result(a, e) {
Ok(a)
Error(e)
}
"
);
}... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/lists.rs | compiler-core/src/format/tests/lists.rs | use crate::{assert_format, assert_format_rewrite};
#[test]
fn list_with_trailing_comma_is_broken() {
assert_format_rewrite!(
"pub fn main() { [ 1, 2, a, ] }",
r#"pub fn main() {
[
1,
2,
a,
]
}
"#
);
}
#[test]
fn constant_list_with_trailing_comma_is_broken() {
assert_format_... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/function.rs | compiler-core/src/format/tests/function.rs | use crate::{assert_format, assert_format_rewrite};
#[test]
fn capture_with_single_argument() {
assert_format_rewrite!(
"pub fn main() -> Nil {
wibble([], wobble(_))
}
",
"pub fn main() -> Nil {
wibble([], wobble)
}
"
);
}
#[test]
fn deprecated() {
assert_format!(
r#"@deprecated... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/asignments.rs | compiler-core/src/format/tests/asignments.rs | use crate::assert_format;
// https://github.com/gleam-lang/gleam/issues/2095
#[test]
fn comment() {
assert_format!(
r#"pub fn main() {
// Hello
let x = 1
x
}
"#
);
}
// https://github.com/gleam-lang/gleam/issues/2095
#[test]
fn assert_comment() {
assert_format!(
r#"pub fn main() {
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/echo.rs | compiler-core/src/format/tests/echo.rs | use crate::{assert_format, assert_format_rewrite};
#[test]
fn echo() {
assert_format!(
"fn main() {
echo
}
"
);
}
#[test]
fn echo_with_value() {
assert_format!(
r#"fn main() {
echo value
}
"#
);
}
#[test]
fn echo_with_big_value_that_needs_to_be_split() {
assert_format!(
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/external_types.rs | compiler-core/src/format/tests/external_types.rs | use crate::assert_format;
#[test]
fn example1() {
assert_format!("type Private\n");
}
#[test]
fn example2() {
assert_format!("type Box(a)\n");
}
#[test]
fn example3() {
assert_format!("type Box(a, b, zero)\n");
}
#[test]
fn example4() {
assert_format!("pub type Private\n");
}
#[test]
fn example5() ... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/tuple.rs | compiler-core/src/format/tests/tuple.rs | use crate::{assert_format, assert_format_rewrite};
// https://github.com/gleam-lang/gleam/issues/2083
#[test]
fn nested_index_block() {
assert_format!(
r#"pub fn main() {
{ #(1, 2).1 }.1
}
"#
);
}
// https://github.com/gleam-lang/gleam/issues/2083
#[test]
fn index_block() {
assert_format!(
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/conditional_compilation.rs | compiler-core/src/format/tests/conditional_compilation.rs | use crate::{assert_format, assert_format_rewrite};
#[test]
fn multiple() {
assert_format!(
"type X
@target(erlang)
type Y {
Y
}
@target(javascript)
type Z {
Z
}
"
);
}
#[test]
fn formatter_removes_target_shorthand_erlang() {
assert_format_rewrite!(
"@target(erl)
fn wibble() {
todo
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/pipeline.rs | compiler-core/src/format/tests/pipeline.rs | use crate::{assert_format, assert_format_rewrite};
#[test]
pub fn single_line_pipeline_longer_than_line_limit_gets_split() {
assert_format_rewrite!(
r#"pub fn main() {
wibble |> wobble |> loooooooooooooooooooooooooooooooooooooooooooong_function_name
}
"#,
r#"pub fn main() {
wibble
|> wobble
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/constant.rs | compiler-core/src/format/tests/constant.rs | use crate::assert_format;
// https://github.com/gleam-lang/gleam/issues/5143
#[test]
pub fn constant_with_deprecated_attribute() {
assert_format!(
r#"@deprecated("Use tau instead")
pub const pi = 3.14
"#
);
}
#[test]
fn const_record_update_simple() {
assert_format!(
r#"pub type Counter {
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/bit_array.rs | compiler-core/src/format/tests/bit_array.rs | use crate::{assert_format, assert_format_rewrite};
#[test]
fn construction() {
assert_format!(
"fn main() {
let a = 1
let x = <<1, a, 2:bytes>>
let size = <<3:2, 4:size(3), 5:bytes-size(4), 6:size(a)>>
let unit = <<7:unit(1), 8:bytes-unit(2)>>
x
}
",
);
}
#[test]
fn pattern() {
assert_fo... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/record_update.rs | compiler-core/src/format/tests/record_update.rs | use crate::assert_format;
#[test]
fn one() {
assert_format!(
"pub type Counter {
Counter(a: Int, b: Int)
}
fn main() {
let c = Counter(0, 0)
let c = Counter(..c, a: c.a + 1, b: c.a + c.b)
c
}
"
);
}
#[test]
fn two() {
// Long record updates are split onto multiple lines
assert_format!... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/blocks.rs | compiler-core/src/format/tests/blocks.rs | use crate::assert_format;
// https://github.com/gleam-lang/gleam/issues/2119
#[test]
fn assignment() {
assert_format!(
r#"fn main() {
let greeting = {
"Hello"
}
greeting
}
"#
);
}
// https://github.com/gleam-lang/gleam/issues/2131
#[test]
fn comment() {
assert_format!(
r#"fn mai... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/cases.rs | compiler-core/src/format/tests/cases.rs | use crate::assert_format;
#[test]
fn case_with_two_long_subjects() {
assert_format!(
r#"pub fn main() {
case
wibble(one_long_argument, something_else),
wobble(another_argument, this_is_long)
{
_ -> todo
}
}
"#
);
}
#[test]
fn multiple_patterns_get_split_one_on_each_line() {
asser... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/format/tests/binary_operators.rs | compiler-core/src/format/tests/binary_operators.rs | use crate::assert_format;
// https://github.com/gleam-lang/gleam/issues/835
#[test]
pub fn long_binary_operation_sequence() {
assert_format!(
r#"pub fn main() {
int.to_string(color.red)
<> ", "
<> int.to_string(color.green)
<> ", "
<> int.to_string(color.blue)
<> ", "
<> float.to_string(color... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/io/memory.rs | compiler-core/src/io/memory.rs | use super::*;
use std::ops::Deref;
use std::{
cell::RefCell,
collections::{HashMap, HashSet},
rc::Rc,
time::Duration,
};
use camino::{Utf8Path, Utf8PathBuf};
/// An in memory sharable collection of pretend files that can be used in place
/// of a real file system. It is a shared reference to a set of ... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/package_interface/tests.rs | compiler-core/src/package_interface/tests.rs | use std::time::SystemTime;
use camino::Utf8PathBuf;
use ecow::EcoString;
use globset::GlobBuilder;
use hexpm::version::Identifier;
use crate::{
analyse::TargetSupport,
build::{Module, Origin, Package, Target},
config::{Docs, ErlangConfig, GleamVersion, JavaScriptConfig, PackageConfig},
line_numbers::L... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/ast/tests.rs | compiler-core/src/ast/tests.rs | use std::sync::Arc;
use camino::Utf8PathBuf;
use ecow::EcoString;
use crate::analyse::TargetSupport;
use crate::build::{ExpressionPosition, Origin, Target};
use crate::config::PackageConfig;
use crate::line_numbers::LineNumbers;
use crate::type_::error::{VariableDeclaration, VariableOrigin, VariableSyntax};
use crate... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/ast/visit.rs | compiler-core/src/ast/visit.rs | //! AST traversal routines, referenced from [`syn::visit`](https://docs.rs/syn/latest/syn/visit/index.html)
//!
//! Each method of the [`Visit`] trait can be overriden to customize the
//! behaviour when visiting the corresponding type of AST node. By default,
//! every method recursively visits the substructure of the... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | true |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/ast/untyped.rs | compiler-core/src/ast/untyped.rs | use vec1::Vec1;
use crate::parse::LiteralFloatValue;
use super::*;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum UntypedExpr {
Int {
location: SrcSpan,
value: EcoString,
int_value: BigInt,
},
Float {
location: SrcSpan,
value: EcoString,
float_value: Lite... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/ast/constant.rs | compiler-core/src/ast/constant.rs | use super::*;
use crate::analyse::Inferred;
use crate::type_::{FieldMap, HasType};
pub type TypedConstant = Constant<Arc<Type>, EcoString>;
pub type UntypedConstant = Constant<(), ()>;
// TODO: remove RecordTag paramter
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Constant<T, RecordTag> {
Int {
locatio... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/ast/typed.rs | compiler-core/src/ast/typed.rs | use std::sync::OnceLock;
use type_::{FieldMap, TypedCallArg};
use super::*;
use crate::{
build::ExpressionPosition,
exhaustiveness::CompiledCase,
parse::LiteralFloatValue,
type_::{HasType, Type, ValueConstructorVariant, bool},
};
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum TypedExpr {
Int {
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | true |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests.rs | compiler-core/src/javascript/tests.rs | use crate::{
analyse::TargetSupport,
build::{Origin, Target},
config::PackageConfig,
inline,
javascript::*,
uid::UniqueIdGenerator,
warning::{TypeWarningEmitter, WarningEmitter},
};
use camino::{Utf8Path, Utf8PathBuf};
mod assert;
mod assignments;
mod bit_arrays;
mod blocks;
mod bools;
mod ... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/typescript.rs | compiler-core/src/javascript/typescript.rs | //! This module is responsible for generating TypeScript type declaration files.
//! This code is run during the code generation phase along side the normal
//! Javascript code emission. Here we walk through the typed AST and translate
//! the Gleam statements into their TypeScript equivalent. Unlike the Javascript
//!... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | true |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/decision.rs | compiler-core/src/javascript/decision.rs | use super::{
INDENT, bit_array_segment_int_value_to_bytes,
expression::{self, Generator, Ordering, float, float_from_value},
};
use crate::{
ast::{AssignmentKind, Endianness, SrcSpan, TypedClause, TypedExpr, TypedPattern},
docvec,
exhaustiveness::{
BitArrayMatchedValue, BitArrayTest, Body, B... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | true |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/expression.rs | compiler-core/src/javascript/expression.rs | use num_bigint::BigInt;
use vec1::Vec1;
use super::{decision::ASSIGNMENT_VAR, *};
use crate::{
ast::*,
exhaustiveness::StringEncoding,
line_numbers::LineNumbers,
pretty::*,
type_::{
ModuleValueConstructor, Type, TypedCallArg, ValueConstructor, ValueConstructorVariant,
},
};
use std::syn... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | true |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/import.rs | compiler-core/src/javascript/import.rs | use std::collections::{HashMap, HashSet};
use ecow::EcoString;
use itertools::Itertools;
use crate::{
docvec,
javascript::{INDENT, JavaScriptCodegenTarget},
pretty::{Document, Documentable, break_, concat, join, line},
};
/// A collection of JavaScript import statements from Gleam imports and from
/// ex... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/consts.rs | compiler-core/src/javascript/tests/consts.rs | use crate::assert_js;
#[test]
fn custom_type_constructor_imported_and_aliased() {
assert_js!(
("package", "other_module", "pub type T { A }"),
r#"import other_module.{A as B}
pub const local = B
"#,
);
}
#[test]
fn imported_aliased_ok() {
assert_js!(
r#"import gleam.{Ok as Y}
pub... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/assert.rs | compiler-core/src/javascript/tests/assert.rs | use crate::assert_js;
#[test]
fn assert_variable() {
assert_js!(
"
pub fn main() {
let x = True
assert x
}
"
);
}
#[test]
fn assert_literal() {
assert_js!(
"
pub fn main() {
assert False
}
"
);
}
#[test]
fn assert_binary_operation() {
assert_js!(
"
pub fn main() {
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/use_.rs | compiler-core/src/javascript/tests/use_.rs | use crate::assert_js;
#[test]
fn arity_1() {
assert_js!(
r#"
pub fn main() {
use <- pair()
123
}
fn pair(f) {
let x = f()
#(x, x)
}
"#,
)
}
#[test]
fn arity_2() {
assert_js!(
r#"
pub fn main() {
use <- pair(1.0)
123
}
fn pair(x, f) {
let y = f()
#(x, y)
}
"#,
)
}
#[t... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/prelude.rs | compiler-core/src/javascript/tests/prelude.rs | use crate::{assert_js, assert_ts_def};
#[test]
fn qualified_ok() {
assert_js!(
r#"import gleam
pub fn go() { gleam.Ok(1) }
"#,
);
}
#[test]
fn qualified_ok_typescript() {
assert_ts_def!(
r#"import gleam
pub fn go() { gleam.Ok(1) }
"#,
);
}
#[test]
fn qualified_error() {
assert_js!... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/case.rs | compiler-core/src/javascript/tests/case.rs | use crate::assert_js;
#[test]
fn case_on_error() {
assert_js!(
r#"
fn a_result() { Error(1) }
pub fn main() {
case a_result() {
Error(_) -> 1
_ -> 2
}
}"#
);
}
#[test]
fn tuple_and_guard() {
assert_js!(
r#"
pub fn go(x) {
case #(1, 2) {
#(1, a) if a == 2 -> 1
#(_, _)... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/case_clause_guards.rs | compiler-core/src/javascript/tests/case_clause_guards.rs | use crate::assert_js;
#[test]
fn referencing_pattern_var() {
assert_js!(
r#"pub fn main(xs) {
case xs {
#(x) if x -> 1
_ -> 0
}
}
"#,
);
}
#[test]
fn rebound_var() {
assert_js!(
r#"pub fn main() {
let x = False
let x = True
case x {
_ if x -> 1
_ -> 0
}
}
"#,
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/modules.rs | compiler-core/src/javascript/tests/modules.rs | use crate::assert_js;
use crate::javascript::tests::CURRENT_PACKAGE;
#[test]
fn empty_module() {
// Renders an export statement to ensure it's an ESModule
assert_js!("", "export {}\n");
}
#[test]
fn unqualified_fn_call() {
assert_js!(
("rocket_ship", r#"pub fn launch() { 1 }"#),
r#"import ... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/results.rs | compiler-core/src/javascript/tests/results.rs | use crate::assert_js;
#[test]
fn ok() {
assert_js!(r#"pub fn main() { Ok(1) }"#);
}
#[test]
fn error() {
assert_js!(r#"pub fn main() { Error(1) }"#);
}
#[test]
fn ok_fn() {
assert_js!(r#"pub fn main() { Ok }"#);
}
#[test]
fn error_fn() {
assert_js!(r#"pub fn main() { Error }"#);
}
#[test]
fn qualif... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/externals.rs | compiler-core/src/javascript/tests/externals.rs | use crate::{assert_js, assert_module_error, assert_ts_def};
#[test]
fn type_() {
assert_js!(r#"pub type Thing"#,);
}
#[test]
fn module_fn() {
assert_js!(
r#"
@external(javascript, "utils", "inspect")
fn show(x: anything) -> Nil"#,
);
}
#[test]
fn at_namespace_module() {
assert_js!(
r#... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/lists.rs | compiler-core/src/javascript/tests/lists.rs | use crate::{assert_js, assert_ts_def};
#[test]
fn list_literals() {
assert_js!(
r#"
pub fn go(x) {
[]
[1]
[1, 2]
[1, 2, ..x]
}
"#,
);
}
#[test]
fn long_list_literals() {
assert_js!(
r#"
pub fn go() {
[111111111111111111111111111111111111111111111111111111111111111111111111]
[11... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/assignments.rs | compiler-core/src/javascript/tests/assignments.rs | use crate::{assert_js, assert_ts_def};
#[test]
fn tuple_matching() {
assert_js!(
r#"
pub fn go(x) {
let assert #(1, 2) = x
}
"#,
)
}
#[test]
fn assert() {
assert_js!(r#"pub fn go(x) { let assert 1 = x }"#,);
}
#[test]
fn assert1() {
assert_js!(r#"pub fn go(x) { let assert #(1, 2) = x }"#,);... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/panic.rs | compiler-core/src/javascript/tests/panic.rs | use crate::{assert_js, assert_ts_def};
#[test]
fn bare() {
assert_js!(
r#"
pub fn go() {
panic
}
"#,
);
}
#[test]
fn panic_as() {
assert_js!(
r#"
pub fn go() {
let x = "wibble"
panic as x
}
"#,
);
}
#[test]
fn bare_typescript() {
assert_ts_def!(
r#"
pub fn go() {
p... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/functions.rs | compiler-core/src/javascript/tests/functions.rs | use crate::{assert_js, assert_ts_def};
#[test]
fn exported_functions() {
assert_js!(
r#"
pub fn add(x, y) {
x + y
}"#,
);
}
#[test]
fn calling_functions() {
assert_js!(
r#"
pub fn twice(f: fn(t) -> t, x: t) -> t {
f(f(x))
}
pub fn add_one(x: Int) -> Int {
x + 1
}
pub fn add_two(x: ... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/recursion.rs | compiler-core/src/javascript/tests/recursion.rs | use crate::assert_js;
#[test]
fn tco() {
assert_js!(
r#"
pub fn main(x) {
case x {
0 -> Nil
_ -> main(x - 1)
}
}
"#
);
}
#[test]
fn tco_case_block() {
assert_js!(
r#"
pub fn main(x) {
case x {
0 -> Nil
_ -> {
let y = x
main(y - 1)
}
}
}
"#
);
}
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/todo.rs | compiler-core/src/javascript/tests/todo.rs | use crate::{assert_js, assert_ts_def};
#[test]
fn without_message() {
assert_js!(
r#"
pub fn go() {
todo
}
"#,
);
}
#[test]
fn without_message_typescript() {
assert_ts_def!(
r#"
pub fn go() {
todo
}
"#,
);
}
#[test]
fn with_message() {
assert_js!(
r#"
pub fn go() {... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/echo.rs | compiler-core/src/javascript/tests/echo.rs | use crate::assert_js;
#[test]
pub fn echo_with_a_simple_expression() {
assert_js!(
r#"
pub fn main() {
echo 1
}
"#
);
}
#[test]
pub fn echo_with_a_simple_expression_and_a_message() {
assert_js!(
r#"
pub fn main() {
echo 1 as "hello!"
}
"#
);
}
#[test]
pub fn echo_with_complex_expr... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/generics.rs | compiler-core/src/javascript/tests/generics.rs | use crate::assert_ts_def;
#[test]
fn fn_generics_typescript() {
assert_ts_def!(
r#"pub fn identity(a) -> a {
a
}
"#,
);
}
#[test]
fn record_generics_typescript() {
assert_ts_def!(
r#"pub type Animal(t) {
Cat(type_: t)
Dog(type_: t)
}
pub fn main() {
Cat(type_: 6)
}
"#,
);
}
#... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/numbers.rs | compiler-core/src/javascript/tests/numbers.rs | use crate::{assert_js, assert_js_module_error};
#[test]
fn int_literals() {
assert_js!(
r#"
pub fn go() {
1
2
-3
4001
0b00001111
0o17
0xF
1_000
}
"#,
);
}
#[test]
fn float_literals() {
assert_js!(
r#"
pub fn go() {
1.5
2.0
-0.1
1.
}
"#,
);
}
#[test]
fn float_sc... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/records.rs | compiler-core/src/javascript/tests/records.rs | use crate::assert_js;
#[test]
fn record_accessors() {
// We can use record accessors for types with only one constructor
assert_js!(
r#"
pub type Person { Person(name: String, age: Int) }
pub fn get_age(person: Person) { person.age }
pub fn get_name(person: Person) { person.name }
"#
);
}
#[test]
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/strings.rs | compiler-core/src/javascript/tests/strings.rs | use crate::assert_js;
#[test]
fn unicode1() {
assert_js!(
r#"
pub fn emoji() -> String {
"\u{1f600}"
}
"#,
);
}
#[test]
fn unicode2() {
assert_js!(
r#"
pub fn y_with_dieresis() -> String {
"\u{0308}y"
}
"#,
);
}
#[test]
fn ascii_as_unicode_escape_sequence() {
assert_js!(
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/bools.rs | compiler-core/src/javascript/tests/bools.rs | use crate::{assert_js, assert_ts_def};
#[test]
fn expressions() {
assert_js!(
r#"
pub fn go() {
True
False
Nil
}
"#
);
}
#[test]
fn constants() {
assert_js!(
r#"
pub const a = True
pub const b = False
pub const c = Nil
"#,
);
}
#[test]
fn constants_typescript() {
asser... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/blocks.rs | compiler-core/src/javascript/tests/blocks.rs | use crate::assert_js;
#[test]
fn block() {
assert_js!(
r#"
pub fn go() {
let x = {
1
2
}
x
}
"#,
);
}
#[test]
fn nested_simple_blocks() {
assert_js!(
r#"
pub fn go() {
let x = {
{
3
}
}
x
}
"#,
);
}
#[test]
fn nested_multiexpr_blocks() {
assert_js... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/tuples.rs | compiler-core/src/javascript/tests/tuples.rs | use crate::{assert_js, assert_ts_def};
#[test]
fn tuple() {
assert_js!(
r#"
pub fn go() {
#("1", "2", "3")
}
"#,
);
}
#[test]
fn tuple1() {
assert_js!(
r#"
pub fn go() {
#(
"1111111111111111111111111111111",
#("1111111111111111111111111111111", "2", "3"),
"3",
)
}
"#,
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/custom_types.rs | compiler-core/src/javascript/tests/custom_types.rs | use crate::javascript::tests::CURRENT_PACKAGE;
use crate::{assert_js, assert_ts_def};
#[test]
fn zero_arity_literal() {
assert_js!(
r#"
pub type Mine {
This
ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchMuchLongerVariant
}
pub fn go() {
This
ThatOneIsAMuchMuchMuchMuchMuchMuchMuchMu... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/type_alias.rs | compiler-core/src/javascript/tests/type_alias.rs | use crate::assert_ts_def;
#[test]
fn type_alias() {
assert_ts_def!(
r#"
pub type Headers = List(#(String, String))
"#,
);
}
#[test]
fn private_type_in_opaque_type() {
assert_ts_def!(
r#"
type PrivateType {
PrivateType
}
pub opaque type OpaqueType {
OpaqueType(PrivateType)
}
"#,
);... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/bit_arrays.rs | compiler-core/src/javascript/tests/bit_arrays.rs | use hexpm::version::Version;
use pubgrub::Range;
use crate::{
assert_js, assert_js_no_warnings_with_gleam_version, assert_js_warnings_with_gleam_version,
assert_ts_def,
};
#[test]
fn empty() {
assert_js!(
r#"
pub fn go() {
<<>>
}
"#,
);
}
#[test]
fn one() {
assert_js!(
r#"
pub f... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | true |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/javascript/tests/inlining.rs | compiler-core/src/javascript/tests/inlining.rs | use crate::assert_js;
const BOOL_MODULE: &str = "
pub fn guard(
when condition: Bool,
return value: a,
otherwise callback: fn() -> a,
) -> a {
case condition {
True -> value
False -> callback()
}
}
pub fn lazy_guard(
when condition: Bool,
return consequence: fn() -> a,
otherwise alternative: f... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests.rs | compiler-core/src/erlang/tests.rs | use std::time::SystemTime;
use camino::Utf8PathBuf;
use crate::analyse::TargetSupport;
use crate::config::PackageConfig;
use crate::type_::PRELUDE_MODULE_NAME;
use crate::warning::WarningEmitter;
use crate::{build, inline};
use crate::{
build::{Origin, Target},
erlang::module,
line_numbers::LineNumbers,
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/pattern.rs | compiler-core/src/erlang/pattern.rs | use ecow::eco_format;
use crate::analyse::Inferred;
use super::*;
pub(super) struct PatternPrinter<'a, 'env> {
pub environment: &'env mut Env<'a>,
pub variables: Vec<&'a str>,
pub guards: Vec<Document<'a>>,
/// In case we're dealing with string patterns, we might have something like
/// this: `"a... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/consts.rs | compiler-core/src/erlang/tests/consts.rs | use crate::assert_erl;
// https://github.com/gleam-lang/gleam/issues/2163
#[test]
fn record_constructor() {
assert_erl!(
r#"
pub type X {
X(Int)
}
pub const z = X
pub fn main() {
z
}"#
);
}
// https://github.com/gleam-lang/gleam/issues/2163
#[test]
fn record_constructor_in_tuple() {
assert_e... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/reserved.rs | compiler-core/src/erlang/tests/reserved.rs | use crate::assert_erl;
#[test]
fn build_in_erlang_type_escaping() {
assert_erl!("pub type Map");
}
#[test]
fn escape_erlang_reserved_keywords_in_type_names() {
// list of all reserved words in erlang
// http://erlang.org/documentation/doc-5.8/doc/reference_manual/introduction.html
assert_erl!(
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/documentation.rs | compiler-core/src/erlang/tests/documentation.rs | use crate::assert_erl;
#[test]
fn function_with_documentation() {
assert_erl!(
r#"
/// Function doc!
pub fn documented() { 1 }"#
);
}
#[test]
fn function_with_multiline_documentation() {
assert_erl!(
r#"
/// Function doc!
/// Hello!!
///
pub fn documented() { 1 }"#
);
}
#[test]
fn quo... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/assert.rs | compiler-core/src/erlang/tests/assert.rs | use crate::assert_erl;
#[test]
fn assert_variable() {
assert_erl!(
"
pub fn main() {
let x = True
assert x
}
"
);
}
#[test]
fn assert_literal() {
assert_erl!(
"
pub fn main() {
assert False
}
"
);
}
#[test]
fn assert_binary_operation() {
assert_erl!(
"
pub fn main() ... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/variables.rs | compiler-core/src/erlang/tests/variables.rs | use crate::assert_erl;
#[test]
fn shadow_let() {
// https://github.com/gleam-lang/gleam/issues/333
assert_erl!(
r#"
pub fn go(a) {
case a {
99 -> {
let a = a
1
}
_ -> a
}
}"#
);
}
#[test]
fn shadow_param() {
// https://github.com/gleam-lang/gleam/issues/772
asse... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/external_fn.rs | compiler-core/src/erlang/tests/external_fn.rs | use crate::{assert_erl, assert_js_module_error, assert_module_error};
#[test]
fn integration_test1_3() {
assert_erl!(
r#"
@external(erlang, "Elixir.MyApp", "run")
pub fn run() -> Int
"#
);
}
#[test]
fn integration_test7() {
assert_erl!(
r#"
@external(erlang, "try", "and")
pub fn receive() ... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/use_.rs | compiler-core/src/erlang/tests/use_.rs | use crate::assert_erl;
#[test]
fn arity_1() {
assert_erl!(
r#"
pub fn main() {
use <- pair()
123
}
fn pair(f) {
let x = f()
#(x, x)
}
"#,
)
}
#[test]
fn arity_2() {
assert_erl!(
r#"
pub fn main() {
use <- pair(1.0)
123
}
fn pair(x, f) {
let y = f()
#(x, y)
}
"#,
)
}
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/prelude.rs | compiler-core/src/erlang/tests/prelude.rs | use crate::assert_erl;
#[test]
fn qualified_prelude() {
assert_erl!(
"import gleam
pub type X { X(gleam.Int) }
"
);
assert_erl!(
"import gleam
pub fn x() { gleam.Ok(1) }
"
);
}
| rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/case.rs | compiler-core/src/erlang/tests/case.rs | use crate::assert_erl;
// https://github.com/gleam-lang/gleam/issues/1675
#[test]
fn alternative_pattern_variable_rewriting() {
assert_erl!(
"
pub fn myfun(mt) {
case mt {
1 | _ ->
1
|> Ok
}
1
|> Ok
}
"
)
}
// https://github.com/gleam-lang/gleam/issues/2349
#[test]
fn positive_... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/guards.rs | compiler-core/src/erlang/tests/guards.rs | use crate::assert_erl;
#[test]
fn clause_guards() {
// Clause guards
assert_erl!(
r#"
pub fn main(args) {
case args {
x if x == args -> 1
_ -> 0
}
}
"#
);
}
#[test]
fn clause_guards_1() {
assert_erl!(
r#"
pub fn main(args) {
case args {
x if {x != x} == {args == args}... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/let_assert.rs | compiler-core/src/erlang/tests/let_assert.rs | use crate::assert_erl;
#[test]
fn one_var() {
// One var
assert_erl!(
r#"pub fn go() {
let assert Ok(y) = Ok(1)
y
}"#
);
}
#[test]
fn more_than_one_var() {
// More vars
assert_erl!(
r#"pub fn go(x) {
let assert [1, a, b, c] = x
[a, b, c]
}"#
);
}
#[test]
fn pattern_let... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/panic.rs | compiler-core/src/erlang/tests/panic.rs | use crate::assert_erl;
#[test]
fn panic_as() {
assert_erl!(
r#"
pub fn main() {
panic as "wibble"
}
"#
);
}
#[test]
fn plain() {
assert_erl!(
r#"
pub fn main() {
panic
}
"#
);
}
#[test]
fn panic_as_function() {
assert_erl!(
r#"
pub fn retstring() {
"wibble"
}
pub fn ... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/functions.rs | compiler-core/src/erlang/tests/functions.rs | use crate::assert_erl;
#[test]
fn function_as_value() {
assert_erl!(
r#"
fn other() {
Nil
}
pub fn main() {
other
}
"#
);
}
#[test]
fn nested_imported_function_as_value() {
assert_erl!(
("package", "some/other", "pub fn wibble() { Nil }"),
r#"
import some/other
pub fn main() ... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/todo.rs | compiler-core/src/erlang/tests/todo.rs | use crate::assert_erl;
#[test]
fn plain() {
assert_erl!(
r#"
pub fn main() {
todo
}
"#
);
}
#[test]
fn todo_as() {
assert_erl!(
r#"
pub fn main() {
todo as "wibble"
}
"#
);
}
#[test]
fn named() {
assert_erl!(
r#"
pub fn main() {
todo as "testing"
}
"#
);
}
#[tes... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/echo.rs | compiler-core/src/erlang/tests/echo.rs | use crate::assert_erl;
#[test]
pub fn echo_with_a_simple_expression() {
assert_erl!(
r#"
pub fn main() {
echo 1
}
"#
);
}
#[test]
pub fn echo_with_a_simple_expression_and_a_message() {
assert_erl!(
r#"
pub fn main() {
echo 1 as "hello!"
}
"#
);
}
#[test]
pub fn echo_with_complex_e... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/type_params.rs | compiler-core/src/erlang/tests/type_params.rs | use crate::assert_erl;
#[test]
fn result_type_inferred_count_once() {
assert_erl!(
"
pub fn wibble() {
let assert Ok(_) = wobble()
}
pub type Wobble(a) {
Wobble
}
pub fn wobble() -> Result(a, Wobble(a)) {
todo
}
"... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/pipes.rs | compiler-core/src/erlang/tests/pipes.rs | use crate::assert_erl;
#[test]
fn clever_pipe_rewriting() {
// a |> b
assert_erl!(
r#"
pub fn apply(f: fn(a) -> b, a: a) { a |> f }
"#
);
}
#[test]
fn clever_pipe_rewriting1() {
// a |> b(c)
assert_erl!(
r#"
pub fn apply(f: fn(a, Int) -> b, a: a) { a |> f(1) }
"#
);
}
// https... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/conditional_compilation.rs | compiler-core/src/erlang/tests/conditional_compilation.rs | use crate::assert_erl;
#[test]
fn excluded_attribute_syntax() {
assert_erl!(
"@target(javascript)
pub fn main() { 1 }
"
);
}
#[test]
fn included_attribute_syntax() {
assert_erl!(
"@target(erlang)
pub fn main() { 1 }
"
);
}
| rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/numbers.rs | compiler-core/src/erlang/tests/numbers.rs | use crate::assert_erl;
#[test]
fn numbers_with_underscores() {
assert_erl!(
r#"
pub fn main() {
100_000
100_000.00101
}
"#
);
}
#[test]
fn numbers_with_underscores1() {
assert_erl!(
r#"
const i = 100_000
const f = 100_000.00101
pub fn main() {
i
f
}
"#
);
}
#[test]
fn numbers_... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/patterns.rs | compiler-core/src/erlang/tests/patterns.rs | use crate::assert_erl;
#[test]
fn alternative_patterns() {
// reassigning name in alternative patterns
assert_erl!(
r#"
pub fn main() {
let duplicate_name = 1
case 1 {
1 | 2 -> {
let duplicate_name = duplicate_name + 1
duplicate_name
}
_ -> 0
}
}"#
);
}
#[test]
fn al... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/records.rs | compiler-core/src/erlang/tests/records.rs | use crate::assert_erl;
use crate::erlang::*;
use crate::type_;
#[test]
fn basic() {
insta::assert_snapshot!(record_definition(
"PetCat",
&[
("name", type_::tuple(vec![])),
("is_cute", type_::tuple(vec![]))
]
));
}
#[test]
fn reserve_words() {
// Reserved wor... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/strings.rs | compiler-core/src/erlang/tests/strings.rs | use crate::assert_erl;
#[test]
fn unicode1() {
assert_erl!(
r#"
pub fn emoji() -> String {
"\u{1f600}"
}
"#,
);
}
#[test]
fn unicode2() {
assert_erl!(
r#"
pub fn y_with_dieresis() -> String {
"\u{0308}y"
}
"#,
);
}
#[test]
fn unicode_concat1() {
assert_erl!(
r#"
pub fn... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/custom_types.rs | compiler-core/src/erlang/tests/custom_types.rs | use crate::assert_erl;
#[test]
fn phantom() {
assert_erl!("pub type Map(k, v)");
}
#[test]
fn annotated_external_type() {
assert_erl!(
r#"
@external(erlang, "gleam_stdlib", "dict")
pub type Dict(key, value)
"#
);
}
#[test]
fn annotated_external_type_used_in_function() {
assert_erl!(
r... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/bit_arrays.rs | compiler-core/src/erlang/tests/bit_arrays.rs | use crate::assert_erl;
#[test]
fn bit_array() {
assert_erl!(
r#"pub fn main() {
let a = 1
let simple = <<1, a>>
let complex = <<4:int-big, 5.0:little-float, 6:native-int>>
let assert <<7:2, 8:size(3), b:bytes-size(4)>> = <<1>>
let assert <<c:8-unit(1), d:bytes-size(2)-unit(2)>> = <<1>>
simple
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/src/erlang/tests/inlining.rs | compiler-core/src/erlang/tests/inlining.rs | use crate::assert_erl;
const BOOL_MODULE: &str = "
pub fn guard(
when condition: Bool,
return value: a,
otherwise callback: fn() -> a,
) -> a {
case condition {
True -> value
False -> callback()
}
}
pub fn lazy_guard(
when condition: Bool,
return consequence: fn() -> a,
otherwise alternative: ... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/compiler-core/generated/schema_capnp.rs | compiler-core/generated/schema_capnp.rs | // @generated by the capnpc-rust plugin to the Cap'n Proto schema compiler.
// DO NOT EDIT.
// source: schema.capnp
pub mod property { /* Value */
#[derive(Copy, Clone)]
pub struct Owned<Value> {
_phantom: ::core::marker::PhantomData<Value>
}
impl <Value> ::capnp::introspect::Introspect for Owned <Value> ... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | true |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/test-package-compiler/build.rs | test-package-compiler/build.rs | use std::path::PathBuf;
pub fn main() {
println!("cargo:rerun-if-changed=cases");
let mut module = "//! This file is generated by build.rs
//! Do not edit it directly, instead add new test cases to ./cases
"
.to_string();
let cases = PathBuf::from("./cases");
let mut names: Vec<_> = std::fs::rea... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/test-package-compiler/src/lib.rs | test-package-compiler/src/lib.rs | #[cfg(test)]
mod generated_tests;
use camino::Utf8PathBuf;
use gleam_core::{
build::{
ErlangAppCodegenConfiguration, Mode, NullTelemetry, Outcome, StaleTracker, Target,
TargetCodegenConfiguration,
},
config::PackageConfig,
io::{FileSystemReader, FileSystemWriter},
warning::{VectorWa... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
gleam-lang/gleam | https://github.com/gleam-lang/gleam/blob/f424547f02e621f1c5f28749786e05eda7feb098/test-package-compiler/src/generated_tests.rs | test-package-compiler/src/generated_tests.rs | //! This file is generated by build.rs
//! Do not edit it directly, instead add new test cases to ./cases
#[rustfmt::skip]
#[test]
fn alias_unqualified_import() {
let output = crate::prepare("./cases/alias_unqualified_import");
insta::assert_snapshot!(
"alias_unqualified_import",
output,
... | rust | Apache-2.0 | f424547f02e621f1c5f28749786e05eda7feb098 | 2026-01-04T15:40:22.554517Z | false |
Rigellute/spotify-tui | https://github.com/Rigellute/spotify-tui/blob/c4dcf6b9fd8318017acbdd7ec005955e26cf2794/src/config.rs | src/config.rs | use super::banner::BANNER;
use anyhow::{anyhow, Error, Result};
use serde::{Deserialize, Serialize};
use std::{
fs,
io::{stdin, Write},
path::{Path, PathBuf},
};
const DEFAULT_PORT: u16 = 8888;
const FILE_NAME: &str = "client.yml";
const CONFIG_DIR: &str = ".config";
const APP_CONFIG_DIR: &str = "spotify-tui";
c... | rust | MIT | c4dcf6b9fd8318017acbdd7ec005955e26cf2794 | 2026-01-04T15:43:14.194500Z | false |
Rigellute/spotify-tui | https://github.com/Rigellute/spotify-tui/blob/c4dcf6b9fd8318017acbdd7ec005955e26cf2794/src/app.rs | src/app.rs | use super::user_config::UserConfig;
use crate::network::IoEvent;
use anyhow::anyhow;
use rspotify::{
model::{
album::{FullAlbum, SavedAlbum, SimplifiedAlbum},
artist::FullArtist,
audio::AudioAnalysis,
context::CurrentlyPlaybackContext,
device::DevicePayload,
page::{CursorBasedPage, Page},
... | rust | MIT | c4dcf6b9fd8318017acbdd7ec005955e26cf2794 | 2026-01-04T15:43:14.194500Z | true |
Rigellute/spotify-tui | https://github.com/Rigellute/spotify-tui/blob/c4dcf6b9fd8318017acbdd7ec005955e26cf2794/src/banner.rs | src/banner.rs | pub const BANNER: &str = "
_________ ____ / /_(_) __/_ __ / /___ __(_)
/ ___/ __ \\/ __ \\/ __/ / /_/ / / /_____/ __/ / / / /
(__ ) /_/ / /_/ / /_/ / __/ /_/ /_____/ /_/ /_/ / /
/____/ .___/\\____/\\__/_/_/ \\__, / \\__/\\__,_/_/
/_/ /____/
";
| rust | MIT | c4dcf6b9fd8318017acbdd7ec005955e26cf2794 | 2026-01-04T15:43:14.194500Z | false |
Rigellute/spotify-tui | https://github.com/Rigellute/spotify-tui/blob/c4dcf6b9fd8318017acbdd7ec005955e26cf2794/src/network.rs | src/network.rs | use crate::app::{
ActiveBlock, AlbumTableContext, App, Artist, ArtistBlock, EpisodeTableContext, RouteId,
ScrollableResultPages, SelectedAlbum, SelectedFullAlbum, SelectedFullShow, SelectedShow,
TrackTableContext,
};
use crate::config::ClientConfig;
use anyhow::anyhow;
use rspotify::{
client::Spotify,
model::... | rust | MIT | c4dcf6b9fd8318017acbdd7ec005955e26cf2794 | 2026-01-04T15:43:14.194500Z | true |
Rigellute/spotify-tui | https://github.com/Rigellute/spotify-tui/blob/c4dcf6b9fd8318017acbdd7ec005955e26cf2794/src/user_config.rs | src/user_config.rs | use crate::event::Key;
use anyhow::{anyhow, Result};
use serde::{Deserialize, Serialize};
use std::{
fs,
path::{Path, PathBuf},
};
use tui::style::Color;
const FILE_NAME: &str = "config.yml";
const CONFIG_DIR: &str = ".config";
const APP_CONFIG_DIR: &str = "spotify-tui";
#[derive(Clone, Debug, Deserialize, Partia... | rust | MIT | c4dcf6b9fd8318017acbdd7ec005955e26cf2794 | 2026-01-04T15:43:14.194500Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.