diff --git a/test/float/invalid_float_data.gleam b/test/float/invalid_float_data.gleam deleted file mode 100644 index 29e21bc..0000000 --- a/test/float/invalid_float_data.gleam +++ /dev/null @@ -1,271 +0,0 @@ -import gleam/list -import parse_error.{ - EmptyString, InvalidDecimalPosition, InvalidExponentSymbolPosition, - InvalidUnderscorePosition, UnknownCharacter, WhitespaceOnlyString, -} -import types.{type FloatTestData, FloatTestData} - -const invalid_empty_or_whitespace: List(FloatTestData) = [ - FloatTestData( - input: "", - output: Error(EmptyString), - python_output: Error(Nil), - ), - FloatTestData( - input: " ", - output: Error(WhitespaceOnlyString), - python_output: Error(Nil), - ), - FloatTestData( - input: "\t", - output: Error(WhitespaceOnlyString), - python_output: Error(Nil), - ), - FloatTestData( - input: "\n", - output: Error(WhitespaceOnlyString), - python_output: Error(Nil), - ), - FloatTestData( - input: "\r", - output: Error(WhitespaceOnlyString), - python_output: Error(Nil), - ), - FloatTestData( - input: "\f", - output: Error(WhitespaceOnlyString), - python_output: Error(Nil), - ), - FloatTestData( - input: "\r\n", - output: Error(WhitespaceOnlyString), - python_output: Error(Nil), - ), - FloatTestData( - input: " \t\n\r\f ", - output: Error(WhitespaceOnlyString), - python_output: Error(Nil), - ), -] - -const invalid_decimal_positions: List(FloatTestData) = [ - FloatTestData( - input: "..1", - output: Error(InvalidDecimalPosition(1)), - python_output: Error(Nil), - ), - FloatTestData( - input: "1..", - output: Error(InvalidDecimalPosition(2)), - python_output: Error(Nil), - ), - FloatTestData( - input: ".1.", - output: Error(InvalidDecimalPosition(2)), - python_output: Error(Nil), - ), - FloatTestData( - input: ".", - output: Error(InvalidDecimalPosition(0)), - python_output: Error(Nil), - ), - FloatTestData( - input: "..", - output: Error(InvalidDecimalPosition(1)), - python_output: Error(Nil), - ), - FloatTestData( - input: " .", - output: Error(InvalidDecimalPosition(1)), - python_output: Error(Nil), - ), -] - -const invalid_underscore_positions: List(FloatTestData) = [ - FloatTestData( - input: "_.", - output: Error(InvalidUnderscorePosition(0)), - python_output: Error(Nil), - ), - FloatTestData( - input: "._", - output: Error(InvalidUnderscorePosition(1)), - python_output: Error(Nil), - ), - FloatTestData( - input: "1_.000", - output: Error(InvalidUnderscorePosition(1)), - python_output: Error(Nil), - ), - FloatTestData( - input: "1._000", - output: Error(InvalidUnderscorePosition(2)), - python_output: Error(Nil), - ), - FloatTestData( - input: "_1000.0", - output: Error(InvalidUnderscorePosition(0)), - python_output: Error(Nil), - ), - FloatTestData( - input: "1000.0_", - output: Error(InvalidUnderscorePosition(6)), - python_output: Error(Nil), - ), - FloatTestData( - input: "1000._0", - output: Error(InvalidUnderscorePosition(5)), - python_output: Error(Nil), - ), - FloatTestData( - input: "1000_.0", - output: Error(InvalidUnderscorePosition(4)), - python_output: Error(Nil), - ), - FloatTestData( - input: "1000_.", - output: Error(InvalidUnderscorePosition(4)), - python_output: Error(Nil), - ), - FloatTestData( - input: "1_000__000.0", - output: Error(InvalidUnderscorePosition(6)), - python_output: Error(Nil), - ), -] - -const invalid_characters: List(FloatTestData) = [ - FloatTestData( - input: ". ", - output: Error(UnknownCharacter(" ", 1)), - python_output: Error(Nil), - ), - FloatTestData( - input: "abc", - output: Error(UnknownCharacter("a", 0)), - python_output: Error(Nil), - ), - FloatTestData( - input: "100.00c01", - output: Error(UnknownCharacter("c", 6)), - python_output: Error(Nil), - ), -] - -const invalid_exponent_positions: List(FloatTestData) = [ - FloatTestData( - input: "e", - output: Error(InvalidExponentSymbolPosition("e", 0)), - python_output: Error(Nil), - ), - FloatTestData( - input: "E", - output: Error(InvalidExponentSymbolPosition("E", 0)), - python_output: Error(Nil), - ), - FloatTestData( - input: "e4", - output: Error(InvalidExponentSymbolPosition("e", 0)), - python_output: Error(Nil), - ), - FloatTestData( - input: "E4", - output: Error(InvalidExponentSymbolPosition("E", 0)), - python_output: Error(Nil), - ), - FloatTestData( - input: "4e", - output: Error(InvalidExponentSymbolPosition("e", 1)), - python_output: Error(Nil), - ), - FloatTestData( - input: "4E", - output: Error(InvalidExponentSymbolPosition("E", 1)), - python_output: Error(Nil), - ), - FloatTestData( - input: ".e", - output: Error(InvalidExponentSymbolPosition("e", 1)), - python_output: Error(Nil), - ), - FloatTestData( - input: ".E", - output: Error(InvalidExponentSymbolPosition("E", 1)), - python_output: Error(Nil), - ), - FloatTestData( - input: ".e4", - output: Error(InvalidExponentSymbolPosition("e", 1)), - python_output: Error(Nil), - ), - FloatTestData( - input: ".E4", - output: Error(InvalidExponentSymbolPosition("E", 1)), - python_output: Error(Nil), - ), - FloatTestData( - input: "4.e", - output: Error(InvalidExponentSymbolPosition("e", 2)), - python_output: Error(Nil), - ), - FloatTestData( - input: "4.E", - output: Error(InvalidExponentSymbolPosition("E", 2)), - python_output: Error(Nil), - ), - FloatTestData( - input: "4e.", - output: Error(InvalidExponentSymbolPosition("e", 1)), - python_output: Error(Nil), - ), - FloatTestData( - input: "4E.", - output: Error(InvalidExponentSymbolPosition("E", 1)), - python_output: Error(Nil), - ), - FloatTestData( - input: "E4.0", - output: Error(InvalidExponentSymbolPosition("E", 0)), - python_output: Error(Nil), - ), - FloatTestData( - input: "4.0E", - output: Error(InvalidExponentSymbolPosition("E", 3)), - python_output: Error(Nil), - ), - FloatTestData( - input: "4.0E_2", - output: Error(InvalidExponentSymbolPosition("E", 3)), - python_output: Error(Nil), - ), - FloatTestData( - input: "1_234.e-4e", - output: Error(InvalidExponentSymbolPosition("e", 9)), - python_output: Error(Nil), - ), -] - -const invalid_mixed: List(FloatTestData) = [ - FloatTestData( - input: "4.0_E2", - output: Error(InvalidUnderscorePosition(3)), - python_output: Error(Nil), - ), - FloatTestData( - input: "1_234.e-4.3", - output: Error(InvalidDecimalPosition(9)), - python_output: Error(Nil), - ), -] - -pub fn data() -> List(FloatTestData) { - [ - invalid_empty_or_whitespace, - invalid_decimal_positions, - invalid_underscore_positions, - invalid_characters, - invalid_exponent_positions, - invalid_mixed, - ] - |> list.flatten -} diff --git a/test/float/valid_float_data.gleam b/test/float/valid_float_data.gleam deleted file mode 100644 index add22f0..0000000 --- a/test/float/valid_float_data.gleam +++ /dev/null @@ -1,76 +0,0 @@ -import gleam/list -import types.{type FloatTestData, FloatTestData} - -const valid_simple_floats: List(FloatTestData) = [ - FloatTestData(input: "1.001", output: Ok(1.001), python_output: Ok("1.001")), - FloatTestData(input: "1.00", output: Ok(1.0), python_output: Ok("1.0")), - FloatTestData(input: "1.0", output: Ok(1.0), python_output: Ok("1.0")), - FloatTestData(input: "0.1", output: Ok(0.1), python_output: Ok("0.1")), - FloatTestData(input: "+1.0", output: Ok(1.0), python_output: Ok("1.0")), - FloatTestData(input: "-1.0", output: Ok(-1.0), python_output: Ok("-1.0")), - FloatTestData( - input: "+123.321", - output: Ok(123.321), - python_output: Ok("123.321"), - ), - FloatTestData( - input: "-123.321", - output: Ok(-123.321), - python_output: Ok("-123.321"), - ), FloatTestData(input: "1", output: Ok(1.0), python_output: Ok("1.0")), - FloatTestData(input: "1.", output: Ok(1.0), python_output: Ok("1.0")), - FloatTestData(input: ".1", output: Ok(0.1), python_output: Ok("0.1")), -] - -const valid_floats_with_underscores: List(FloatTestData) = [ - FloatTestData( - input: "1_000_000.0", - output: Ok(1_000_000.0), - python_output: Ok("1000000.0"), - ), - FloatTestData( - input: "1_000_000.000_1", - output: Ok(1_000_000.0001), - python_output: Ok("1000000.0001"), - ), - FloatTestData( - input: "1000.000_000", - output: Ok(1000.0), - python_output: Ok("1000.0"), - ), -] - -const valid_floats_with_whitespace: List(FloatTestData) = [ - FloatTestData(input: " 1 ", output: Ok(1.0), python_output: Ok("1.0")), - FloatTestData(input: " 1.0 ", output: Ok(1.0), python_output: Ok("1.0")), - FloatTestData( - input: " 1000 ", - output: Ok(1000.0), - python_output: Ok("1000.0"), - ), -] - -const valid_floats_with_exponents: List(FloatTestData) = [ - FloatTestData(input: "4e3", output: Ok(4000.0), python_output: Ok("4000.0")), - FloatTestData(input: "4e-3", output: Ok(0.004), python_output: Ok("0.004")), - FloatTestData(input: "4.0e3", output: Ok(4000.0), python_output: Ok("4000.0")), - FloatTestData(input: "4.0e-3", output: Ok(0.004), python_output: Ok("0.004")), - FloatTestData(input: "4E3", output: Ok(4000.0), python_output: Ok("4000.0")), - FloatTestData(input: "4E-3", output: Ok(0.004), python_output: Ok("0.004")), - FloatTestData(input: "4.0E3", output: Ok(4000.0), python_output: Ok("4000.0")), - FloatTestData(input: "4.0E-3", output: Ok(0.004), python_output: Ok("0.004")), - FloatTestData(input: ".3e3", output: Ok(300.0), python_output: Ok("300.0")), - FloatTestData(input: ".3e-3", output: Ok(0.0003), python_output: Ok("0.0003")), - FloatTestData(input: "3.e3", output: Ok(3000.0), python_output: Ok("3000.0")), - FloatTestData(input: "3.e-3", output: Ok(0.003), python_output: Ok("0.003")), -] - -pub fn data() -> List(FloatTestData) { - [ - valid_simple_floats, - valid_floats_with_underscores, - valid_floats_with_whitespace, - valid_floats_with_exponents, - ] - |> list.flatten -}