aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/old/vlib/v/gen/js/sourcemap/compare_test.v
diff options
context:
space:
mode:
Diffstat (limited to 'v_windows/v/old/vlib/v/gen/js/sourcemap/compare_test.v')
-rw-r--r--v_windows/v/old/vlib/v/gen/js/sourcemap/compare_test.v322
1 files changed, 322 insertions, 0 deletions
diff --git a/v_windows/v/old/vlib/v/gen/js/sourcemap/compare_test.v b/v_windows/v/old/vlib/v/gen/js/sourcemap/compare_test.v
new file mode 100644
index 0000000..0a755be
--- /dev/null
+++ b/v_windows/v/old/vlib/v/gen/js/sourcemap/compare_test.v
@@ -0,0 +1,322 @@
+module sourcemap
+
+fn test_cmp_eq() {
+ a := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: IndexNumber(3)
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ b := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: IndexNumber(3)
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ assert !compare_by_generated_positions_inflated(a, b)
+}
+
+fn test_cmp_name() {
+ a := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: IndexNumber(3)
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ b := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: IndexNumber(4)
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ assert compare_by_generated_positions_inflated(a, b)
+}
+
+fn test_cmp_name_empty() {
+ a := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: IndexNumber(3)
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ b := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ assert compare_by_generated_positions_inflated(a, b)
+}
+
+fn test_cmp_name_empty_empty() {
+ a := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ b := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ assert !compare_by_generated_positions_inflated(a, b)
+}
+
+fn test_cmp_source_position_empty_eq() {
+ a := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: Empty{}
+ }
+
+ b := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: Empty{}
+ }
+
+ assert !compare_by_generated_positions_inflated(a, b)
+}
+
+fn test_cmp_source_position_empty_diff() {
+ a := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ b := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: Empty{}
+ }
+
+ assert compare_by_generated_positions_inflated(a, b)
+}
+
+fn test_cmp_source_position_column_diff() {
+ a := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ b := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 99
+ }
+ }
+
+ assert compare_by_generated_positions_inflated(a, b)
+}
+
+fn test_cmp_source_position_line_diff() {
+ a := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ b := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: SourcePosition{
+ source_line: 88
+ source_column: 99
+ }
+ }
+
+ assert compare_by_generated_positions_inflated(a, b)
+}
+
+fn test_cmp_sources() {
+ a := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ b := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 99
+ names_ind: Empty{}
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ assert compare_by_generated_positions_inflated(a, b)
+}
+
+fn test_cmp_gen_column() {
+ a := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ b := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 99
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ assert compare_by_generated_positions_inflated(a, b)
+}
+
+fn test_cmp_gen_line() {
+ a := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 0
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ b := Mapping{
+ GenPosition: GenPosition{
+ gen_line: 1
+ gen_column: 99
+ }
+ sources_ind: 2
+ names_ind: Empty{}
+ source_position: SourcePosition{
+ source_line: 4
+ source_column: 5
+ }
+ }
+
+ assert compare_by_generated_positions_inflated(a, b)
+}