Fixed some tests
This commit is contained in:
parent
77b43b9595
commit
ffe8008bb9
|
|
@ -440,6 +440,8 @@ static LexerResult parse_numeric_type(LexerInfo *lexer_info, char c, size_t star
|
||||||
return lexer_error(lexer_info, SLS_STR("Invalid numeric literal: float type not allowed."), start, start_line);
|
return lexer_error(lexer_info, SLS_STR("Invalid numeric literal: float type not allowed."), start, start_line);
|
||||||
}
|
}
|
||||||
} else if (c == 'i' || c == 'u') {
|
} else if (c == 'i' || c == 'u') {
|
||||||
|
if (numeric_literal_type == NUMERIC_FLOAT || numeric_literal_type == NUMERIC_EXPONENTIAL)
|
||||||
|
return lexer_error(lexer_info, SLS_STR("Invalid float type: must be of type 'f64' or 'f32'."), start, start_line);
|
||||||
if (c == 'u') numeric_type |= NUMERIC_UNSIGNED;
|
if (c == 'u') numeric_type |= NUMERIC_UNSIGNED;
|
||||||
c = advance(lexer_info);
|
c = advance(lexer_info);
|
||||||
if (c == '6' && far_peek(lexer_info, 1) == '4') {
|
if (c == '6' && far_peek(lexer_info, 1) == '4') {
|
||||||
|
|
@ -539,7 +541,7 @@ static LexerResult parse_float(LexerInfo *lexer_info, char c, size_t start, size
|
||||||
if (c == ':') return parse_numeric_type(lexer_info, c, start, start_line, NUMERIC_FLOAT);
|
if (c == ':') return parse_numeric_type(lexer_info, c, start, start_line, NUMERIC_FLOAT);
|
||||||
if (isspace(c) || c == '/' || c == '\0')
|
if (isspace(c) || c == '/' || c == '\0')
|
||||||
return create_float_token(lexer_info, NUMERIC_F64, start, start_line);
|
return create_float_token(lexer_info, NUMERIC_F64, start, start_line);
|
||||||
SlsStr error_msg = sls_format(SLS_STR("Invalid float literal: unexpected '%c' in float literal."), c);
|
SlsStr error_msg = sls_format(SLS_STR("Invalid float literal: unexpected '%c' in float."), c);
|
||||||
if (error_msg.str == NULL) return (LexerResult){SLS_ERROR, .error = (SlsError){SLS_STR("Out Of Memory Error."), 1}};
|
if (error_msg.str == NULL) return (LexerResult){SLS_ERROR, .error = (SlsError){SLS_STR("Out Of Memory Error."), 1}};
|
||||||
return lexer_error(lexer_info, error_msg, start, start_line);
|
return lexer_error(lexer_info, error_msg, start, start_line);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#include "tests/tests.h"
|
#include "tests/tests.h"
|
||||||
|
|
||||||
|
|
||||||
static const size_t NUM_OF_TESTS = 482;
|
static const size_t NUM_OF_TESTS = 448;
|
||||||
|
|
||||||
static TestResult test_Empty_Statement() {
|
static TestResult test_Empty_Statement() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Empty_Statement"), SLS_STR(""));
|
LexerTest test = start_up_test(SLS_STR("Empty_Statement"), SLS_STR(""));
|
||||||
|
|
@ -1478,46 +1478,6 @@ static TestResult test_Float_Default_No_Trailing_Digits_Negative() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Float_Default_Scientific_Positive_Exp() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Default Scientific Positive Exp"), SLS_STR("1.5e10"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){15000000000.0})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Default_Scientific_Negative_Exp() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Default Scientific Negative Exp"), SLS_STR("2.5e-5"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){2.5e-05})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Default_Scientific_Capital_E() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Default Scientific Capital E"), SLS_STR("3.14E8"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){314000000.0})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Default_Scientific_Plus_Sign() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Default Scientific Plus Sign"), SLS_STR("1.0e+3"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){1000.0})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Default_Very_Small() {
|
static TestResult test_Float_Default_Very_Small() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Default Very Small"), SLS_STR("0.000001"));
|
LexerTest test = start_up_test(SLS_STR("Float Default Very Small"), SLS_STR("0.000001"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
|
|
@ -1528,16 +1488,6 @@ static TestResult test_Float_Default_Very_Small() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Float_Default_Scientific_Very_Small() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Default Scientific Very Small"), SLS_STR("1.0e-20"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){1e-20})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Default_Very_Large() {
|
static TestResult test_Float_Default_Very_Large() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Default Very Large"), SLS_STR("1000000.0"));
|
LexerTest test = start_up_test(SLS_STR("Float Default Very Large"), SLS_STR("1000000.0"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
|
|
@ -1548,16 +1498,6 @@ static TestResult test_Float_Default_Very_Large() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Float_Default_Scientific_Very_Large() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Default Scientific Very Large"), SLS_STR("1.0e20"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){1e+20})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Default_Underscore_Integer_Part() {
|
static TestResult test_Float_Default_Underscore_Integer_Part() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Default Underscore Integer Part"), SLS_STR("1_000_000.5"));
|
LexerTest test = start_up_test(SLS_STR("Float Default Underscore Integer Part"), SLS_STR("1_000_000.5"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
|
|
@ -1588,26 +1528,6 @@ static TestResult test_Float_Default_Underscore_Both_Parts() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Float_Default_Underscore_Scientific_Mantissa() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Default Underscore Scientific Mantissa"), SLS_STR("1_000.5e10"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){10005000000000.0})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Default_Underscore_Scientific_Exponent() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Default Underscore Scientific Exponent"), SLS_STR("1.5e1_0"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){15000000000.0})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Default_Underscore_Trailing() {
|
static TestResult test_Float_Default_Underscore_Trailing() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Default Underscore Trailing"), SLS_STR("42.5_"));
|
LexerTest test = start_up_test(SLS_STR("Float Default Underscore Trailing"), SLS_STR("42.5_"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
|
|
@ -1638,182 +1558,6 @@ static TestResult test_Float_f32_With_Underscores() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Float_f32_Max_Value() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f32 Max Value"), SLS_STR("3.4028235e+38:f32"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_float_value(&test, result, i++, &(float){3.4028235e+38})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f32_Min_Value() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f32 Min Value"), SLS_STR("-3.4028235e+38:f32"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_float_value(&test, result, i++, &(float){-3.4028235e+38})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f32_Min_Positive() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f32 Min Positive"), SLS_STR("1.1754944e-38:f32"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_float_value(&test, result, i++, &(float){1.1754944e-38})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f32_Epsilon() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f32 Epsilon"), SLS_STR("1.1920929e-07:f32"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_float_value(&test, result, i++, &(float){1.1920929e-07})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f32_Near_Zero_Positive() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f32 Near Zero Positive"), SLS_STR("1e-30:f32"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_float_value(&test, result, i++, &(float){1e-30})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f32_Near_Zero_Negative() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f32 Near Zero Negative"), SLS_STR("-1e-30:f32"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_float_value(&test, result, i++, &(float){-1e-30})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f32_Subnormal() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f32 Subnormal"), SLS_STR("1e-40:f32"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_float_value(&test, result, i++, &(float){1e-40})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f64_Max_Value() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f64 Max Value"), SLS_STR("1.7976931348623157e+308:f64"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){1.7976931348623157e+308})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f64_Min_Value() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f64 Min Value"), SLS_STR("-1.7976931348623157e+308:f64"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){-1.7976931348623157e+308})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f64_Min_Positive() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f64 Min Positive"), SLS_STR("2.2250738585072014e-308:f64"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){2.2250738585072014e-308})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f64_Epsilon() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f64 Epsilon"), SLS_STR("2.220446049250313e-16:f64"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){2.220446049250313e-16})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f64_Near_Zero_Positive() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f64 Near Zero Positive"), SLS_STR("1e-30:f64"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){1e-30})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f64_Near_Zero_Negative() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f64 Near Zero Negative"), SLS_STR("-1e-30:f64"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){-1e-30})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f64_Subnormal() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f64 Subnormal"), SLS_STR("1e-320:f64"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_double_value(&test, result, i++, &(double){1e-320})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f32_Overflow_Positive() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f32 Overflow Positive"), SLS_STR("1e40:f32"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Float overflow: value exceeds range for f32."))) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f32_Overflow_Negative() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f32 Overflow Negative"), SLS_STR("-1e40:f32"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Float overflow: value exceeds range for f32."))) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f64_Overflow_Positive() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f64 Overflow Positive"), SLS_STR("1e310:f64"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Float overflow: value exceeds range for f64."))) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f64_Overflow_Negative() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f64 Overflow Negative"), SLS_STR("-1e310:f64"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Float overflow: value exceeds range for f64."))) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_f32_Precision_Limit() {
|
static TestResult test_Float_f32_Precision_Limit() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Float f32 Precision Limit"), SLS_STR("1.2345678:f32"));
|
LexerTest test = start_up_test(SLS_STR("Float f32 Precision Limit"), SLS_STR("1.2345678:f32"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
|
|
@ -1874,30 +1618,12 @@ static TestResult test_Float_f64_Close_Numbers_2() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Float_Invalid_No_Decimal_Point() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Invalid No Decimal Point"), SLS_STR("42"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Not a valid float literal: missing decimal point."))) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Invalid_Multiple_Decimal_Points() {
|
static TestResult test_Float_Invalid_Multiple_Decimal_Points() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Invalid Multiple Decimal Points"), SLS_STR("3.14.159"));
|
LexerTest test = start_up_test(SLS_STR("Float Invalid Multiple Decimal Points"), SLS_STR("3.14.159"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Invalid float literal: multiple decimal points."))) return test.result;
|
if (test_for_error(&test, result, i++, SLS_STR("Invalid float literal: unexpected '.' in float."))) return test.result;
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Invalid_Only_Decimal_Point() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Invalid Only Decimal Point"), SLS_STR("."));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Invalid float literal: no digits before or after decimal point."))) return test.result;
|
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1910,66 +1636,12 @@ static TestResult test_Float_Invalid_Characters() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Float_Invalid_Scientific_No_Exponent() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Invalid Scientific No Exponent"), SLS_STR("3.14e"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Invalid float literal: missing exponent value."))) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Invalid_Scientific_Double_E() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Invalid Scientific Double E"), SLS_STR("3.14e10e5"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Invalid float literal: multiple exponent markers."))) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Invalid_Scientific_Invalid_Exponent() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Invalid Scientific Invalid Exponent"), SLS_STR("3.14eX"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Invalid float literal: invalid exponent 'X'."))) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Invalid_Leading_Underscore() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Invalid Leading Underscore"), SLS_STR("_3.14"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Invalid float literal: leading underscore."))) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Invalid_Underscore_Before_Decimal() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Invalid Underscore Before Decimal"), SLS_STR("3_.14"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Invalid float literal: underscore before decimal point."))) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Invalid_Underscore_After_Decimal() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Invalid Underscore After Decimal"), SLS_STR("3._14"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Invalid float literal: underscore after decimal point."))) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Float_Invalid_Type_Annotation() {
|
static TestResult test_Float_Invalid_Type_Annotation() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Float Invalid Type Annotation"), SLS_STR("3.14:i32"));
|
LexerTest test = start_up_test(SLS_STR("Float Invalid Type Annotation"), SLS_STR("3.14:i32"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Type mismatch: float literal cannot be annotated as integer type."))) return test.result;
|
if (test_for_error(&test, result, i++, SLS_STR("Invalid float type: must be of type 'f64' or 'f32'."))) return test.result;
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1978,7 +1650,7 @@ static TestResult test_Float_Invalid_Type_Name() {
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
if (test_for_error(&test, result, i++, SLS_STR("Invalid type annotation: unknown type 'f16'."))) return test.result;
|
if (test_for_error(&test, result, i++, SLS_STR("Invalid float type: must be of type 'f64' or 'f32'."))) return test.result;
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2401,42 +2073,12 @@ static TestResult test_Char_Right_Brace() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Char_Escape_Backslash() {
|
static TestResult test_Char_Escape_Null_character() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Char Escape Backslash"), SLS_STR("'\\'"));
|
LexerTest test = start_up_test(SLS_STR("Char Escape Null character"), SLS_STR("'\0'"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
if (test_character_value(&test, result, i++, &(uint8_t){92})) return test.result;
|
if (test_character_value(&test, result, i++, &(uint8_t){0})) return test.result;
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Char_Escape_Double_quote() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Char Escape Double quote"), SLS_STR("'\\\"'"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_character_value(&test, result, i++, &(uint8_t){34})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Char_Escape_Newline() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Char Escape Newline"), SLS_STR("'\n'"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_character_value(&test, result, i++, &(uint8_t){10})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
|
||||||
return pass_test(&test, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TestResult test_Char_Escape_Single_quote() {
|
|
||||||
LexerTest test = start_up_test(SLS_STR("Char Escape Single quote"), SLS_STR("'\''"));
|
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
|
||||||
size_t i = 0;
|
|
||||||
if (test_character_value(&test, result, i++, &(uint8_t){39})) return test.result;
|
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
@ -2451,12 +2093,12 @@ static TestResult test_Char_Escape_Tab() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestResult test_Char_Escape_Null_character() {
|
static TestResult test_Char_Escape_Double_quote() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Char Escape Null character"), SLS_STR("'\0'"));
|
LexerTest test = start_up_test(SLS_STR("Char Escape Double quote"), SLS_STR("'\\\"'"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
if (test_character_value(&test, result, i++, &(uint8_t){0})) return test.result;
|
if (test_character_value(&test, result, i++, &(uint8_t){34})) return test.result;
|
||||||
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
@ -2471,6 +2113,36 @@ static TestResult test_Char_Escape_Carriage_return() {
|
||||||
return pass_test(&test, result);
|
return pass_test(&test, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static TestResult test_Char_Escape_Backslash() {
|
||||||
|
LexerTest test = start_up_test(SLS_STR("Char Escape Backslash"), SLS_STR("'\\'"));
|
||||||
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
|
size_t i = 0;
|
||||||
|
if (test_character_value(&test, result, i++, &(uint8_t){92})) return test.result;
|
||||||
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
||||||
|
return pass_test(&test, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static TestResult test_Char_Escape_Single_quote() {
|
||||||
|
LexerTest test = start_up_test(SLS_STR("Char Escape Single quote"), SLS_STR("'\''"));
|
||||||
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
|
size_t i = 0;
|
||||||
|
if (test_character_value(&test, result, i++, &(uint8_t){39})) return test.result;
|
||||||
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
||||||
|
return pass_test(&test, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static TestResult test_Char_Escape_Newline() {
|
||||||
|
LexerTest test = start_up_test(SLS_STR("Char Escape Newline"), SLS_STR("'\n'"));
|
||||||
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
|
if (result.type == SLS_ERROR) return error_fail_test(&test, result, result.error);
|
||||||
|
size_t i = 0;
|
||||||
|
if (test_character_value(&test, result, i++, &(uint8_t){10})) return test.result;
|
||||||
|
if (test_eof_value(&test, result, i++, 0)) return test.result;
|
||||||
|
return pass_test(&test, result);
|
||||||
|
}
|
||||||
|
|
||||||
static TestResult test_Char_Newline() {
|
static TestResult test_Char_Newline() {
|
||||||
LexerTest test = start_up_test(SLS_STR("Char Newline"), SLS_STR("'\n'"));
|
LexerTest test = start_up_test(SLS_STR("Char Newline"), SLS_STR("'\n'"));
|
||||||
LexerResult result = lexical_analysis(&test.lexer_info);
|
LexerResult result = lexical_analysis(&test.lexer_info);
|
||||||
|
|
@ -4913,56 +4585,22 @@ TestsReport run_lexer_tests() {
|
||||||
test_report.tests[i++] = test_Float_Default_No_Leading_Digit_Negative();
|
test_report.tests[i++] = test_Float_Default_No_Leading_Digit_Negative();
|
||||||
test_report.tests[i++] = test_Float_Default_No_Trailing_Digits();
|
test_report.tests[i++] = test_Float_Default_No_Trailing_Digits();
|
||||||
test_report.tests[i++] = test_Float_Default_No_Trailing_Digits_Negative();
|
test_report.tests[i++] = test_Float_Default_No_Trailing_Digits_Negative();
|
||||||
test_report.tests[i++] = test_Float_Default_Scientific_Positive_Exp();
|
|
||||||
test_report.tests[i++] = test_Float_Default_Scientific_Negative_Exp();
|
|
||||||
test_report.tests[i++] = test_Float_Default_Scientific_Capital_E();
|
|
||||||
test_report.tests[i++] = test_Float_Default_Scientific_Plus_Sign();
|
|
||||||
test_report.tests[i++] = test_Float_Default_Very_Small();
|
test_report.tests[i++] = test_Float_Default_Very_Small();
|
||||||
test_report.tests[i++] = test_Float_Default_Scientific_Very_Small();
|
|
||||||
test_report.tests[i++] = test_Float_Default_Very_Large();
|
test_report.tests[i++] = test_Float_Default_Very_Large();
|
||||||
test_report.tests[i++] = test_Float_Default_Scientific_Very_Large();
|
|
||||||
test_report.tests[i++] = test_Float_Default_Underscore_Integer_Part();
|
test_report.tests[i++] = test_Float_Default_Underscore_Integer_Part();
|
||||||
test_report.tests[i++] = test_Float_Default_Underscore_Decimal_Part();
|
test_report.tests[i++] = test_Float_Default_Underscore_Decimal_Part();
|
||||||
test_report.tests[i++] = test_Float_Default_Underscore_Both_Parts();
|
test_report.tests[i++] = test_Float_Default_Underscore_Both_Parts();
|
||||||
test_report.tests[i++] = test_Float_Default_Underscore_Scientific_Mantissa();
|
|
||||||
test_report.tests[i++] = test_Float_Default_Underscore_Scientific_Exponent();
|
|
||||||
test_report.tests[i++] = test_Float_Default_Underscore_Trailing();
|
test_report.tests[i++] = test_Float_Default_Underscore_Trailing();
|
||||||
test_report.tests[i++] = test_Float_Default_Underscore_Double();
|
test_report.tests[i++] = test_Float_Default_Underscore_Double();
|
||||||
test_report.tests[i++] = test_Float_f32_With_Underscores();
|
test_report.tests[i++] = test_Float_f32_With_Underscores();
|
||||||
test_report.tests[i++] = test_Float_f32_Max_Value();
|
|
||||||
test_report.tests[i++] = test_Float_f32_Min_Value();
|
|
||||||
test_report.tests[i++] = test_Float_f32_Min_Positive();
|
|
||||||
test_report.tests[i++] = test_Float_f32_Epsilon();
|
|
||||||
test_report.tests[i++] = test_Float_f32_Near_Zero_Positive();
|
|
||||||
test_report.tests[i++] = test_Float_f32_Near_Zero_Negative();
|
|
||||||
test_report.tests[i++] = test_Float_f32_Subnormal();
|
|
||||||
test_report.tests[i++] = test_Float_f64_Max_Value();
|
|
||||||
test_report.tests[i++] = test_Float_f64_Min_Value();
|
|
||||||
test_report.tests[i++] = test_Float_f64_Min_Positive();
|
|
||||||
test_report.tests[i++] = test_Float_f64_Epsilon();
|
|
||||||
test_report.tests[i++] = test_Float_f64_Near_Zero_Positive();
|
|
||||||
test_report.tests[i++] = test_Float_f64_Near_Zero_Negative();
|
|
||||||
test_report.tests[i++] = test_Float_f64_Subnormal();
|
|
||||||
test_report.tests[i++] = test_Float_f32_Overflow_Positive();
|
|
||||||
test_report.tests[i++] = test_Float_f32_Overflow_Negative();
|
|
||||||
test_report.tests[i++] = test_Float_f64_Overflow_Positive();
|
|
||||||
test_report.tests[i++] = test_Float_f64_Overflow_Negative();
|
|
||||||
test_report.tests[i++] = test_Float_f32_Precision_Limit();
|
test_report.tests[i++] = test_Float_f32_Precision_Limit();
|
||||||
test_report.tests[i++] = test_Float_f32_High_Precision();
|
test_report.tests[i++] = test_Float_f32_High_Precision();
|
||||||
test_report.tests[i++] = test_Float_f64_Precision_Limit();
|
test_report.tests[i++] = test_Float_f64_Precision_Limit();
|
||||||
test_report.tests[i++] = test_Float_f64_High_Precision();
|
test_report.tests[i++] = test_Float_f64_High_Precision();
|
||||||
test_report.tests[i++] = test_Float_f64_Close_Numbers_1();
|
test_report.tests[i++] = test_Float_f64_Close_Numbers_1();
|
||||||
test_report.tests[i++] = test_Float_f64_Close_Numbers_2();
|
test_report.tests[i++] = test_Float_f64_Close_Numbers_2();
|
||||||
test_report.tests[i++] = test_Float_Invalid_No_Decimal_Point();
|
|
||||||
test_report.tests[i++] = test_Float_Invalid_Multiple_Decimal_Points();
|
test_report.tests[i++] = test_Float_Invalid_Multiple_Decimal_Points();
|
||||||
test_report.tests[i++] = test_Float_Invalid_Only_Decimal_Point();
|
|
||||||
test_report.tests[i++] = test_Float_Invalid_Characters();
|
test_report.tests[i++] = test_Float_Invalid_Characters();
|
||||||
test_report.tests[i++] = test_Float_Invalid_Scientific_No_Exponent();
|
|
||||||
test_report.tests[i++] = test_Float_Invalid_Scientific_Double_E();
|
|
||||||
test_report.tests[i++] = test_Float_Invalid_Scientific_Invalid_Exponent();
|
|
||||||
test_report.tests[i++] = test_Float_Invalid_Leading_Underscore();
|
|
||||||
test_report.tests[i++] = test_Float_Invalid_Underscore_Before_Decimal();
|
|
||||||
test_report.tests[i++] = test_Float_Invalid_Underscore_After_Decimal();
|
|
||||||
test_report.tests[i++] = test_Float_Invalid_Type_Annotation();
|
test_report.tests[i++] = test_Float_Invalid_Type_Annotation();
|
||||||
test_report.tests[i++] = test_Float_Invalid_Type_Name();
|
test_report.tests[i++] = test_Float_Invalid_Type_Name();
|
||||||
test_report.tests[i++] = test_Float_Invalid_Comma_Separator();
|
test_report.tests[i++] = test_Float_Invalid_Comma_Separator();
|
||||||
|
|
@ -5007,13 +4645,13 @@ TestsReport run_lexer_tests() {
|
||||||
test_report.tests[i++] = test_Char_Right_Bracket();
|
test_report.tests[i++] = test_Char_Right_Bracket();
|
||||||
test_report.tests[i++] = test_Char_Left_Brace();
|
test_report.tests[i++] = test_Char_Left_Brace();
|
||||||
test_report.tests[i++] = test_Char_Right_Brace();
|
test_report.tests[i++] = test_Char_Right_Brace();
|
||||||
test_report.tests[i++] = test_Char_Escape_Backslash();
|
|
||||||
test_report.tests[i++] = test_Char_Escape_Double_quote();
|
|
||||||
test_report.tests[i++] = test_Char_Escape_Newline();
|
|
||||||
test_report.tests[i++] = test_Char_Escape_Single_quote();
|
|
||||||
test_report.tests[i++] = test_Char_Escape_Tab();
|
|
||||||
test_report.tests[i++] = test_Char_Escape_Null_character();
|
test_report.tests[i++] = test_Char_Escape_Null_character();
|
||||||
|
test_report.tests[i++] = test_Char_Escape_Tab();
|
||||||
|
test_report.tests[i++] = test_Char_Escape_Double_quote();
|
||||||
test_report.tests[i++] = test_Char_Escape_Carriage_return();
|
test_report.tests[i++] = test_Char_Escape_Carriage_return();
|
||||||
|
test_report.tests[i++] = test_Char_Escape_Backslash();
|
||||||
|
test_report.tests[i++] = test_Char_Escape_Single_quote();
|
||||||
|
test_report.tests[i++] = test_Char_Escape_Newline();
|
||||||
test_report.tests[i++] = test_Char_Newline();
|
test_report.tests[i++] = test_Char_Newline();
|
||||||
test_report.tests[i++] = test_Char_Carriage_Return();
|
test_report.tests[i++] = test_Char_Carriage_Return();
|
||||||
test_report.tests[i++] = test_Char_Tab();
|
test_report.tests[i++] = test_Char_Tab();
|
||||||
|
|
|
||||||
|
|
@ -1632,54 +1632,6 @@
|
||||||
stack_final:
|
stack_final:
|
||||||
- type: f64
|
- type: f64
|
||||||
value: -7.0
|
value: -7.0
|
||||||
- name: Float Default Scientific Positive Exp
|
|
||||||
code: 1.5e10
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: 15000000000.0
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: 15000000000.0
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: 15000000000.0
|
|
||||||
- name: Float Default Scientific Negative Exp
|
|
||||||
code: '2.5e-5'
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: 2.5e-05
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: 2.5e-05
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: 2.5e-05
|
|
||||||
- name: Float Default Scientific Capital E
|
|
||||||
code: 3.14E8
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: 314000000.0
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: 314000000.0
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: 314000000.0
|
|
||||||
- name: Float Default Scientific Plus Sign
|
|
||||||
code: '1.0e+3'
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: 1000.0
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: 1000.0
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: 1000.0
|
|
||||||
- name: Float Default Very Small
|
- name: Float Default Very Small
|
||||||
code: '0.000001'
|
code: '0.000001'
|
||||||
tokens:
|
tokens:
|
||||||
|
|
@ -1692,18 +1644,6 @@
|
||||||
stack_final:
|
stack_final:
|
||||||
- type: f64
|
- type: f64
|
||||||
value: 1.0e-06
|
value: 1.0e-06
|
||||||
- name: Float Default Scientific Very Small
|
|
||||||
code: '1.0e-20'
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: 1.0e-20
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: 1.0e-20
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: 1.0e-20
|
|
||||||
- name: Float Default Very Large
|
- name: Float Default Very Large
|
||||||
code: '1000000.0'
|
code: '1000000.0'
|
||||||
tokens:
|
tokens:
|
||||||
|
|
@ -1716,18 +1656,6 @@
|
||||||
stack_final:
|
stack_final:
|
||||||
- type: f64
|
- type: f64
|
||||||
value: 1000000.0
|
value: 1000000.0
|
||||||
- name: Float Default Scientific Very Large
|
|
||||||
code: 1.0e20
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: 1.0e+20
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: 1.0e+20
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: 1.0e+20
|
|
||||||
- name: Float Default Underscore Integer Part
|
- name: Float Default Underscore Integer Part
|
||||||
code: '1_000_000.5'
|
code: '1_000_000.5'
|
||||||
tokens:
|
tokens:
|
||||||
|
|
@ -1764,30 +1692,6 @@
|
||||||
stack_final:
|
stack_final:
|
||||||
- type: f64
|
- type: f64
|
||||||
value: 1234.56789
|
value: 1234.56789
|
||||||
- name: Float Default Underscore Scientific Mantissa
|
|
||||||
code: 1_000.5e10
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: 10005000000000.0
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: 10005000000000.0
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: 10005000000000.0
|
|
||||||
- name: Float Default Underscore Scientific Exponent
|
|
||||||
code: 1.5e1_0
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: 15000000000.0
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: 15000000000.0
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: 15000000000.0
|
|
||||||
- name: Float Default Underscore Trailing
|
- name: Float Default Underscore Trailing
|
||||||
code: '42.5_'
|
code: '42.5_'
|
||||||
tokens:
|
tokens:
|
||||||
|
|
@ -1824,194 +1728,6 @@
|
||||||
stack_final:
|
stack_final:
|
||||||
- type: f32
|
- type: f32
|
||||||
value: 1234.56789
|
value: 1234.56789
|
||||||
- name: Float f32 Max Value
|
|
||||||
code: 3.4028235e+38:f32
|
|
||||||
tokens:
|
|
||||||
- type: f32
|
|
||||||
value: 3.4028235e+38
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f32
|
|
||||||
value: 3.4028235e+38
|
|
||||||
stack_final:
|
|
||||||
- type: f32
|
|
||||||
value: 3.4028235e+38
|
|
||||||
- name: Float f32 Min Value
|
|
||||||
code: -3.4028235e+38:f32
|
|
||||||
tokens:
|
|
||||||
- type: f32
|
|
||||||
value: -3.4028235e+38
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f32
|
|
||||||
value: -3.4028235e+38
|
|
||||||
stack_final:
|
|
||||||
- type: f32
|
|
||||||
value: -3.4028235e+38
|
|
||||||
- name: Float f32 Min Positive
|
|
||||||
code: 1.1754944e-38:f32
|
|
||||||
tokens:
|
|
||||||
- type: f32
|
|
||||||
value: 1.1754944e-38
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f32
|
|
||||||
value: 1.1754944e-38
|
|
||||||
stack_final:
|
|
||||||
- type: f32
|
|
||||||
value: 1.1754944e-38
|
|
||||||
- name: Float f32 Epsilon
|
|
||||||
code: 1.1920929e-07:f32
|
|
||||||
tokens:
|
|
||||||
- type: f32
|
|
||||||
value: 1.1920929e-07
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f32
|
|
||||||
value: 1.1920929e-07
|
|
||||||
stack_final:
|
|
||||||
- type: f32
|
|
||||||
value: 1.1920929e-07
|
|
||||||
- name: Float f32 Near Zero Positive
|
|
||||||
code: 1e-30:f32
|
|
||||||
tokens:
|
|
||||||
- type: f32
|
|
||||||
value: 1.0e-30
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f32
|
|
||||||
value: 1.0e-30
|
|
||||||
stack_final:
|
|
||||||
- type: f32
|
|
||||||
value: 1.0e-30
|
|
||||||
- name: Float f32 Near Zero Negative
|
|
||||||
code: -1e-30:f32
|
|
||||||
tokens:
|
|
||||||
- type: f32
|
|
||||||
value: -1.0e-30
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f32
|
|
||||||
value: -1.0e-30
|
|
||||||
stack_final:
|
|
||||||
- type: f32
|
|
||||||
value: -1.0e-30
|
|
||||||
- name: Float f32 Subnormal
|
|
||||||
code: 1e-40:f32
|
|
||||||
tokens:
|
|
||||||
- type: f32
|
|
||||||
value: 1.0e-40
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f32
|
|
||||||
value: 1.0e-40
|
|
||||||
stack_final:
|
|
||||||
- type: f32
|
|
||||||
value: 1.0e-40
|
|
||||||
- name: Float f64 Max Value
|
|
||||||
code: 1.7976931348623157e+308:f64
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: 1.7976931348623157e+308
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: 1.7976931348623157e+308
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: 1.7976931348623157e+308
|
|
||||||
- name: Float f64 Min Value
|
|
||||||
code: -1.7976931348623157e+308:f64
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: -1.7976931348623157e+308
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: -1.7976931348623157e+308
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: -1.7976931348623157e+308
|
|
||||||
- name: Float f64 Min Positive
|
|
||||||
code: 2.2250738585072014e-308:f64
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: 2.2250738585072014e-308
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: 2.2250738585072014e-308
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: 2.2250738585072014e-308
|
|
||||||
- name: Float f64 Epsilon
|
|
||||||
code: 2.220446049250313e-16:f64
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: 2.220446049250313e-16
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: 2.220446049250313e-16
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: 2.220446049250313e-16
|
|
||||||
- name: Float f64 Near Zero Positive
|
|
||||||
code: 1e-30:f64
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: 1.0e-30
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: 1.0e-30
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: 1.0e-30
|
|
||||||
- name: Float f64 Near Zero Negative
|
|
||||||
code: -1e-30:f64
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: -1.0e-30
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: -1.0e-30
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: -1.0e-30
|
|
||||||
- name: Float f64 Subnormal
|
|
||||||
code: 1e-320:f64
|
|
||||||
tokens:
|
|
||||||
- type: f64
|
|
||||||
value: 1.0e-320
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: f64
|
|
||||||
value: 1.0e-320
|
|
||||||
stack_final:
|
|
||||||
- type: f64
|
|
||||||
value: 1.0e-320
|
|
||||||
- name: Float f32 Overflow Positive
|
|
||||||
code: 1e40:f32
|
|
||||||
tokens:
|
|
||||||
- type: error
|
|
||||||
value: 'Float overflow: value exceeds range for f32.'
|
|
||||||
- name: Float f32 Overflow Negative
|
|
||||||
code: -1e40:f32
|
|
||||||
tokens:
|
|
||||||
- type: error
|
|
||||||
value: 'Float overflow: value exceeds range for f32.'
|
|
||||||
- name: Float f64 Overflow Positive
|
|
||||||
code: 1e310:f64
|
|
||||||
tokens:
|
|
||||||
- type: error
|
|
||||||
value: 'Float overflow: value exceeds range for f64.'
|
|
||||||
- name: Float f64 Overflow Negative
|
|
||||||
code: -1e310:f64
|
|
||||||
tokens:
|
|
||||||
- type: error
|
|
||||||
value: 'Float overflow: value exceeds range for f64.'
|
|
||||||
- name: Float f32 Precision Limit
|
- name: Float f32 Precision Limit
|
||||||
code: 1.2345678:f32
|
code: 1.2345678:f32
|
||||||
tokens:
|
tokens:
|
||||||
|
|
@ -2084,66 +1800,26 @@
|
||||||
stack_final:
|
stack_final:
|
||||||
- type: f64
|
- type: f64
|
||||||
value: 1.0000000000000002
|
value: 1.0000000000000002
|
||||||
- name: Float Invalid No Decimal Point
|
|
||||||
code: '42'
|
|
||||||
tokens:
|
|
||||||
- type: error
|
|
||||||
value: 'Not a valid float literal: missing decimal point.'
|
|
||||||
- name: Float Invalid Multiple Decimal Points
|
- name: Float Invalid Multiple Decimal Points
|
||||||
code: 3.14.159
|
code: 3.14.159
|
||||||
tokens:
|
tokens:
|
||||||
- type: error
|
- type: error
|
||||||
value: 'Invalid float literal: multiple decimal points.'
|
value: 'Invalid float literal: unexpected ''.'' in float.'
|
||||||
- name: Float Invalid Only Decimal Point
|
|
||||||
code: .
|
|
||||||
tokens:
|
|
||||||
- type: error
|
|
||||||
value: 'Invalid float literal: no digits before or after decimal point.'
|
|
||||||
- name: Float Invalid Characters
|
- name: Float Invalid Characters
|
||||||
code: 3.1a4
|
code: 3.1a4
|
||||||
tokens:
|
tokens:
|
||||||
- type: error
|
- type: error
|
||||||
value: 'Invalid float literal: unexpected ''a'' in float.'
|
value: 'Invalid float literal: unexpected ''a'' in float.'
|
||||||
- name: Float Invalid Scientific No Exponent
|
|
||||||
code: 3.14e
|
|
||||||
tokens:
|
|
||||||
- type: error
|
|
||||||
value: 'Invalid float literal: missing exponent value.'
|
|
||||||
- name: Float Invalid Scientific Double E
|
|
||||||
code: 3.14e10e5
|
|
||||||
tokens:
|
|
||||||
- type: error
|
|
||||||
value: 'Invalid float literal: multiple exponent markers.'
|
|
||||||
- name: Float Invalid Scientific Invalid Exponent
|
|
||||||
code: 3.14eX
|
|
||||||
tokens:
|
|
||||||
- type: error
|
|
||||||
value: 'Invalid float literal: invalid exponent ''X''.'
|
|
||||||
- name: Float Invalid Leading Underscore
|
|
||||||
code: _3.14
|
|
||||||
tokens:
|
|
||||||
- type: error
|
|
||||||
value: 'Invalid float literal: leading underscore.'
|
|
||||||
- name: Float Invalid Underscore Before Decimal
|
|
||||||
code: '3_.14'
|
|
||||||
tokens:
|
|
||||||
- type: error
|
|
||||||
value: 'Invalid float literal: underscore before decimal point.'
|
|
||||||
- name: Float Invalid Underscore After Decimal
|
|
||||||
code: '3._14'
|
|
||||||
tokens:
|
|
||||||
- type: error
|
|
||||||
value: 'Invalid float literal: underscore after decimal point.'
|
|
||||||
- name: Float Invalid Type Annotation
|
- name: Float Invalid Type Annotation
|
||||||
code: 3.14:i32
|
code: 3.14:i32
|
||||||
tokens:
|
tokens:
|
||||||
- type: error
|
- type: error
|
||||||
value: 'Type mismatch: float literal cannot be annotated as integer type.'
|
value: 'Invalid float type: must be of type ''f64'' or ''f32''.'
|
||||||
- name: Float Invalid Type Name
|
- name: Float Invalid Type Name
|
||||||
code: 3.14:f16
|
code: 3.14:f16
|
||||||
tokens:
|
tokens:
|
||||||
- type: error
|
- type: error
|
||||||
value: 'Invalid type annotation: unknown type ''f16''.'
|
value: 'Invalid float type: must be of type ''f64'' or ''f32''.'
|
||||||
- name: Float Invalid Comma Separator
|
- name: Float Invalid Comma Separator
|
||||||
code: 1,234.56
|
code: 1,234.56
|
||||||
tokens:
|
tokens:
|
||||||
|
|
@ -2641,18 +2317,30 @@
|
||||||
stack_final:
|
stack_final:
|
||||||
- type: char
|
- type: char
|
||||||
value: '}'
|
value: '}'
|
||||||
- name: Char Escape Backslash
|
- name: Char Escape Null character
|
||||||
code: '''\\'''
|
code: '''\0'''
|
||||||
tokens:
|
tokens:
|
||||||
- type: char
|
- type: char
|
||||||
value: \
|
value: "\0"
|
||||||
operations:
|
operations:
|
||||||
- function: push
|
- function: push
|
||||||
type: char
|
type: char
|
||||||
value: \
|
value: "\0"
|
||||||
stack_final:
|
stack_final:
|
||||||
- type: char
|
- type: char
|
||||||
value: \
|
value: "\0"
|
||||||
|
- name: Char Escape Tab
|
||||||
|
code: '''\t'''
|
||||||
|
tokens:
|
||||||
|
- type: char
|
||||||
|
value: "\t"
|
||||||
|
operations:
|
||||||
|
- function: push
|
||||||
|
type: char
|
||||||
|
value: "\t"
|
||||||
|
stack_final:
|
||||||
|
- type: char
|
||||||
|
value: "\t"
|
||||||
- name: Char Escape Double quote
|
- name: Char Escape Double quote
|
||||||
code: '''\\"'''
|
code: '''\\"'''
|
||||||
tokens:
|
tokens:
|
||||||
|
|
@ -2665,6 +2353,42 @@
|
||||||
stack_final:
|
stack_final:
|
||||||
- type: char
|
- type: char
|
||||||
value: '"'
|
value: '"'
|
||||||
|
- name: Char Escape Carriage return
|
||||||
|
code: '''\r'''
|
||||||
|
tokens:
|
||||||
|
- type: char
|
||||||
|
value: "\r"
|
||||||
|
operations:
|
||||||
|
- function: push
|
||||||
|
type: char
|
||||||
|
value: "\r"
|
||||||
|
stack_final:
|
||||||
|
- type: char
|
||||||
|
value: "\r"
|
||||||
|
- name: Char Escape Backslash
|
||||||
|
code: '''\\'''
|
||||||
|
tokens:
|
||||||
|
- type: char
|
||||||
|
value: \
|
||||||
|
operations:
|
||||||
|
- function: push
|
||||||
|
type: char
|
||||||
|
value: \
|
||||||
|
stack_final:
|
||||||
|
- type: char
|
||||||
|
value: \
|
||||||
|
- name: Char Escape Single quote
|
||||||
|
code: '''\'''''
|
||||||
|
tokens:
|
||||||
|
- type: char
|
||||||
|
value: ''''
|
||||||
|
operations:
|
||||||
|
- function: push
|
||||||
|
type: char
|
||||||
|
value: ''''
|
||||||
|
stack_final:
|
||||||
|
- type: char
|
||||||
|
value: ''''
|
||||||
- name: Char Escape Newline
|
- name: Char Escape Newline
|
||||||
code: '''\n'''
|
code: '''\n'''
|
||||||
tokens:
|
tokens:
|
||||||
|
|
@ -2683,54 +2407,6 @@
|
||||||
value: '
|
value: '
|
||||||
|
|
||||||
'
|
'
|
||||||
- name: Char Escape Single quote
|
|
||||||
code: '''\'''''
|
|
||||||
tokens:
|
|
||||||
- type: char
|
|
||||||
value: ''''
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: char
|
|
||||||
value: ''''
|
|
||||||
stack_final:
|
|
||||||
- type: char
|
|
||||||
value: ''''
|
|
||||||
- name: Char Escape Tab
|
|
||||||
code: '''\t'''
|
|
||||||
tokens:
|
|
||||||
- type: char
|
|
||||||
value: "\t"
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: char
|
|
||||||
value: "\t"
|
|
||||||
stack_final:
|
|
||||||
- type: char
|
|
||||||
value: "\t"
|
|
||||||
- name: Char Escape Null character
|
|
||||||
code: '''\0'''
|
|
||||||
tokens:
|
|
||||||
- type: char
|
|
||||||
value: "\0"
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: char
|
|
||||||
value: "\0"
|
|
||||||
stack_final:
|
|
||||||
- type: char
|
|
||||||
value: "\0"
|
|
||||||
- name: Char Escape Carriage return
|
|
||||||
code: '''\r'''
|
|
||||||
tokens:
|
|
||||||
- type: char
|
|
||||||
value: "\r"
|
|
||||||
operations:
|
|
||||||
- function: push
|
|
||||||
type: char
|
|
||||||
value: "\r"
|
|
||||||
stack_final:
|
|
||||||
- type: char
|
|
||||||
value: "\r"
|
|
||||||
- name: Char Newline
|
- name: Char Newline
|
||||||
code: '''\n'''
|
code: '''\n'''
|
||||||
tokens:
|
tokens:
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ class BaseTestGenerator(ABC):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ENABLE_UNICODE = False
|
ENABLE_UNICODE = False
|
||||||
|
ENABLE_EXPONENTIAL_LITERALS = False
|
||||||
|
|
||||||
__generators: "ClassVar[List[Type[BaseTestGenerator]]]" = []
|
__generators: "ClassVar[List[Type[BaseTestGenerator]]]" = []
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ class FloatTestGenerator(BaseTestGenerator):
|
||||||
self.make_success_test("Float Default No Trailing Digits", "42.", "f64", 42.0)
|
self.make_success_test("Float Default No Trailing Digits", "42.", "f64", 42.0)
|
||||||
self.make_success_test("Float Default No Trailing Digits Negative", "-7.", "f64", -7.0)
|
self.make_success_test("Float Default No Trailing Digits Negative", "-7.", "f64", -7.0)
|
||||||
|
|
||||||
|
if self.ENABLE_EXPONENTIAL_LITERALS:
|
||||||
# Scientific notation
|
# Scientific notation
|
||||||
self.make_success_test("Float Default Scientific Positive Exp", "1.5e10", "f64", 1.5e10)
|
self.make_success_test("Float Default Scientific Positive Exp", "1.5e10", "f64", 1.5e10)
|
||||||
self.make_success_test("Float Default Scientific Negative Exp", "2.5e-5", "f64", 2.5e-5)
|
self.make_success_test("Float Default Scientific Negative Exp", "2.5e-5", "f64", 2.5e-5)
|
||||||
|
|
@ -57,10 +58,12 @@ class FloatTestGenerator(BaseTestGenerator):
|
||||||
|
|
||||||
# Very small numbers
|
# Very small numbers
|
||||||
self.make_success_test("Float Default Very Small", "0.000001", "f64", 0.000001)
|
self.make_success_test("Float Default Very Small", "0.000001", "f64", 0.000001)
|
||||||
|
if self.ENABLE_EXPONENTIAL_LITERALS:
|
||||||
self.make_success_test("Float Default Scientific Very Small", "1.0e-20", "f64", 1.0e-20)
|
self.make_success_test("Float Default Scientific Very Small", "1.0e-20", "f64", 1.0e-20)
|
||||||
|
|
||||||
# Very large numbers
|
# Very large numbers
|
||||||
self.make_success_test("Float Default Very Large", "1000000.0", "f64", 1000000.0)
|
self.make_success_test("Float Default Very Large", "1000000.0", "f64", 1000000.0)
|
||||||
|
if self.ENABLE_EXPONENTIAL_LITERALS:
|
||||||
self.make_success_test("Float Default Scientific Very Large", "1.0e20", "f64", 1.0e20)
|
self.make_success_test("Float Default Scientific Very Large", "1.0e20", "f64", 1.0e20)
|
||||||
|
|
||||||
def generate_underscore_tests(self):
|
def generate_underscore_tests(self):
|
||||||
|
|
@ -77,6 +80,7 @@ class FloatTestGenerator(BaseTestGenerator):
|
||||||
self.make_success_test("Float Default Underscore Both Parts",
|
self.make_success_test("Float Default Underscore Both Parts",
|
||||||
"1_234.567_89", "f64", 1234.56789)
|
"1_234.567_89", "f64", 1234.56789)
|
||||||
|
|
||||||
|
if self.ENABLE_EXPONENTIAL_LITERALS:
|
||||||
# Underscores in scientific notation
|
# Underscores in scientific notation
|
||||||
self.make_success_test("Float Default Underscore Scientific Mantissa",
|
self.make_success_test("Float Default Underscore Scientific Mantissa",
|
||||||
"1_000.5e10", "f64", 1000.5e10)
|
"1_000.5e10", "f64", 1000.5e10)
|
||||||
|
|
@ -112,6 +116,7 @@ class FloatTestGenerator(BaseTestGenerator):
|
||||||
"""Generate edge case tests for a specific float type."""
|
"""Generate edge case tests for a specific float type."""
|
||||||
values = self.SPECIAL_VALUES[type_name]
|
values = self.SPECIAL_VALUES[type_name]
|
||||||
|
|
||||||
|
if self.ENABLE_EXPONENTIAL_LITERALS:
|
||||||
# Maximum value
|
# Maximum value
|
||||||
self.make_success_test(f"Float {type_name} Max Value",
|
self.make_success_test(f"Float {type_name} Max Value",
|
||||||
f"{values['max']}:{type_name}", type_name, values['max'])
|
f"{values['max']}:{type_name}", type_name, values['max'])
|
||||||
|
|
@ -146,6 +151,7 @@ class FloatTestGenerator(BaseTestGenerator):
|
||||||
|
|
||||||
def generate_overflow_tests(self):
|
def generate_overflow_tests(self):
|
||||||
"""Generate overflow tests."""
|
"""Generate overflow tests."""
|
||||||
|
if self.ENABLE_EXPONENTIAL_LITERALS:
|
||||||
# f32 overflow
|
# f32 overflow
|
||||||
self.make_error_test("Float f32 Overflow Positive",
|
self.make_error_test("Float f32 Overflow Positive",
|
||||||
"1e40:f32",
|
"1e40:f32",
|
||||||
|
|
@ -185,48 +191,32 @@ class FloatTestGenerator(BaseTestGenerator):
|
||||||
def generate_error_tests(self):
|
def generate_error_tests(self):
|
||||||
"""Generate error tests."""
|
"""Generate error tests."""
|
||||||
# Invalid formats
|
# Invalid formats
|
||||||
self.make_error_test("Float Invalid No Decimal Point",
|
|
||||||
"42",
|
|
||||||
"Not a valid float literal: missing decimal point.")
|
|
||||||
self.make_error_test("Float Invalid Multiple Decimal Points",
|
self.make_error_test("Float Invalid Multiple Decimal Points",
|
||||||
"3.14.159",
|
"3.14.159",
|
||||||
"Invalid float literal: multiple decimal points.")
|
"Invalid float literal: unexpected '.' in float.")
|
||||||
self.make_error_test("Float Invalid Only Decimal Point",
|
|
||||||
".",
|
|
||||||
"Invalid float literal: no digits before or after decimal point.")
|
|
||||||
self.make_error_test("Float Invalid Characters",
|
self.make_error_test("Float Invalid Characters",
|
||||||
"3.1a4",
|
"3.1a4",
|
||||||
"Invalid float literal: unexpected 'a' in float.")
|
"Invalid float literal: unexpected 'a' in float.")
|
||||||
|
|
||||||
|
if self.ENABLE_EXPONENTIAL_LITERALS:
|
||||||
# Invalid scientific notation
|
# Invalid scientific notation
|
||||||
self.make_error_test("Float Invalid Scientific No Exponent",
|
self.make_error_test("Float Invalid Scientific No Exponent",
|
||||||
"3.14e",
|
"3.14e",
|
||||||
"Invalid float literal: missing exponent value.")
|
"Invalid float literal: missing exponent value.")
|
||||||
self.make_error_test("Float Invalid Scientific Double E",
|
self.make_error_test("Float Invalid Scientific Double E",
|
||||||
"3.14e10e5",
|
"3.14e10e5",
|
||||||
"Invalid float literal: multiple exponent markers.")
|
"Invalid float literal: unexpected 'e' in float.")
|
||||||
self.make_error_test("Float Invalid Scientific Invalid Exponent",
|
self.make_error_test("Float Invalid Scientific Invalid Exponent",
|
||||||
"3.14eX",
|
"3.14eX",
|
||||||
"Invalid float literal: invalid exponent 'X'.")
|
"Invalid float literal: unexpected 'X' in float.")
|
||||||
|
|
||||||
# Invalid underscores
|
|
||||||
self.make_error_test("Float Invalid Leading Underscore",
|
|
||||||
"_3.14",
|
|
||||||
"Invalid float literal: leading underscore.")
|
|
||||||
self.make_error_test("Float Invalid Underscore Before Decimal",
|
|
||||||
"3_.14",
|
|
||||||
"Invalid float literal: underscore before decimal point.")
|
|
||||||
self.make_error_test("Float Invalid Underscore After Decimal",
|
|
||||||
"3._14",
|
|
||||||
"Invalid float literal: underscore after decimal point.")
|
|
||||||
|
|
||||||
# Invalid type annotations
|
# Invalid type annotations
|
||||||
self.make_error_test("Float Invalid Type Annotation",
|
self.make_error_test("Float Invalid Type Annotation",
|
||||||
"3.14:i32",
|
"3.14:i32",
|
||||||
"Type mismatch: float literal cannot be annotated as integer type.")
|
"Invalid float type: must be of type 'f64' or 'f32'.")
|
||||||
self.make_error_test("Float Invalid Type Name",
|
self.make_error_test("Float Invalid Type Name",
|
||||||
"3.14:f16",
|
"3.14:f16",
|
||||||
"Invalid type annotation: unknown type 'f16'.")
|
"Invalid float type: must be of type 'f64' or 'f32'.")
|
||||||
|
|
||||||
# Comma separators not allowed
|
# Comma separators not allowed
|
||||||
self.make_error_test("Float Invalid Comma Separator",
|
self.make_error_test("Float Invalid Comma Separator",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue