Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

Update tests to be clearer

+68 -61
+20 -14
language-server/src/tests/action.rs
··· 12142 12142 option: option.Option(String), 12143 12143 dict: dict.Dict(Int, Bool), 12144 12144 ) 12145 - Wimble( 12145 + Dummy( 12146 12146 a: Int, 12147 12147 b: Int, 12148 12148 c: Int, ··· 12182 12182 12183 12183 pub type Wobble { 12184 12184 Wobble(value: Wibble) 12185 - Wimble(a: Int, b: Int) 12185 + Dummy(a: Int, b: Int) 12186 12186 } 12187 12187 "#; 12188 12188 assert_code_action!( ··· 12206 12206 #[test] 12207 12207 fn generate_dynamic_decoder_produces_zero_values_for_user_defined_type_in_the_same_package_2() { 12208 12208 let src = r#" 12209 - import wibble.{type Wibble} 12209 + import internal/wibble.{type Wibble} 12210 12210 12211 12211 pub type Wobble { 12212 12212 Wobble(value: Wibble) 12213 - Wimble(a: Int, b: Int) 12213 + Dummy(a: Int, b: Int) 12214 12214 } 12215 12215 "#; 12216 12216 assert_code_action!( 12217 12217 GENERATE_DYNAMIC_DECODER, 12218 - TestProject::for_source(src).add_module( 12219 - "wibble", 12220 - r#" 12218 + TestProject::for_source(src) 12219 + .add_module( 12220 + "internal/wibble", 12221 + r#" 12222 + import internal/nested_wibble.{type NestedWibble} 12221 12223 pub type Wibble { Wibble(value: NestedWibble) } 12222 - 12224 + "# 12225 + ) 12226 + .add_module( 12227 + "internal/nested_wibble", 12228 + r#" 12223 12229 pub type NestedWibble { NestedWibble } 12224 12230 "# 12225 - ), 12231 + ), 12226 12232 find_position_of("pub type Wobble {").select_until(find_position_of("}").nth_occurrence(2)) 12227 12233 ); 12228 12234 } ··· 12234 12240 12235 12241 pub type Wobble { 12236 12242 Wobble(value: Wibble) 12237 - Wimble(a: Int, b: Int) 12243 + Dummy(a: Int, b: Int) 12238 12244 } 12239 12245 "#; 12240 12246 assert_code_action!( ··· 12265 12271 12266 12272 pub type Wobble { 12267 12273 Wobble(value: Wibble) 12268 - Wimble(a: Int, b: Int) 12274 + Dummy(a: Int, b: Int) 12269 12275 } 12270 12276 "#; 12271 12277 assert_code_action!( ··· 12282 12288 r#" 12283 12289 pub type Wobble { 12284 12290 Wobble(inside: Wobble) 12285 - Wimble(a: Int, b: Int) 12291 + Dummy(a: Int, b: Int) 12286 12292 } 12287 12293 "#, 12288 12294 find_position_of("pub type Wobble {").select_until(find_position_of("}")) ··· 12296 12302 r#" 12297 12303 pub type Wobble { 12298 12304 Wobble(inside: Wibble) 12299 - Womble(a: Int, b: Int) 12305 + Dummy(a: Int, b: Int) 12300 12306 } 12301 12307 12302 12308 pub type Wibble { 12303 12309 Wibble(inside: Wobble) 12304 - Wimble(a: Int, b: Int) 12310 + Dummy(a: Int, b: Int) 12305 12311 } 12306 12312 "#, 12307 12313 find_position_of("pub type Wobble {").select_until(find_position_of("}"))
+6 -6
language-server/src/tests/snapshots/gleam_language_server__tests__action__generate_dynamic_decoder_does_not_produce_zero_values_for_recursively_defined_constructors_1.snap
··· 1 1 --- 2 2 source: language-server/src/tests/action.rs 3 - expression: "\npub type Wobble {\n Wobble(inside: Wobble)\n Wimble(a: Int, b: Int)\n}\n " 3 + expression: "\npub type Wobble {\n Wobble(inside: Wobble)\n Dummy(a: Int, b: Int)\n}\n " 4 4 --- 5 5 ----- BEFORE ACTION 6 6 ··· 8 8 ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 9 9 Wobble(inside: Wobble) 10 10 ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 11 - Wimble(a: Int, b: Int) 12 - ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 11 + Dummy(a: Int, b: Int) 12 + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 13 13 } 14 14 15 15 ··· 20 20 21 21 pub type Wobble { 22 22 Wobble(inside: Wobble) 23 - Wimble(a: Int, b: Int) 23 + Dummy(a: Int, b: Int) 24 24 } 25 25 26 26 fn wobble_decoder() -> decode.Decoder(Wobble) { ··· 30 30 use inside <- decode.field("inside", wobble_decoder()) 31 31 decode.success(Wobble(inside:)) 32 32 } 33 - "wimble" -> { 33 + "dummy" -> { 34 34 use a <- decode.field("a", decode.int) 35 35 use b <- decode.field("b", decode.int) 36 - decode.success(Wimble(a:, b:)) 36 + decode.success(Dummy(a:, b:)) 37 37 } 38 38 _ -> decode.failure(todo as "Zero value for Wobble", "Wobble") 39 39 }
+8 -8
language-server/src/tests/snapshots/gleam_language_server__tests__action__generate_dynamic_decoder_does_not_produce_zero_values_for_recursively_defined_constructors_2.snap
··· 1 1 --- 2 2 source: language-server/src/tests/action.rs 3 - expression: "\npub type Wobble {\n Wobble(inside: Wibble)\n Womble(a: Int, b: Int)\n}\n\npub type Wibble {\n Wibble(inside: Wobble)\n Wimble(a: Int, b: Int)\n}\n " 3 + expression: "\npub type Wobble {\n Wobble(inside: Wibble)\n Dummy(a: Int, b: Int)\n}\n\npub type Wibble {\n Wibble(inside: Wobble)\n Dummy(a: Int, b: Int)\n}\n " 4 4 --- 5 5 ----- BEFORE ACTION 6 6 ··· 8 8 ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 9 9 Wobble(inside: Wibble) 10 10 ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 11 - Womble(a: Int, b: Int) 12 - ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 11 + Dummy(a: Int, b: Int) 12 + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 13 13 } 14 14 15 15 16 16 pub type Wibble { 17 17 Wibble(inside: Wobble) 18 - Wimble(a: Int, b: Int) 18 + Dummy(a: Int, b: Int) 19 19 } 20 20 21 21 ··· 25 25 26 26 pub type Wobble { 27 27 Wobble(inside: Wibble) 28 - Womble(a: Int, b: Int) 28 + Dummy(a: Int, b: Int) 29 29 } 30 30 31 31 fn wobble_decoder() -> decode.Decoder(Wobble) { ··· 35 35 use inside <- decode.field("inside", todo as "Decoder for Wibble") 36 36 decode.success(Wobble(inside:)) 37 37 } 38 - "womble" -> { 38 + "dummy" -> { 39 39 use a <- decode.field("a", decode.int) 40 40 use b <- decode.field("b", decode.int) 41 - decode.success(Womble(a:, b:)) 41 + decode.success(Dummy(a:, b:)) 42 42 } 43 43 _ -> decode.failure(todo as "Zero value for Wobble", "Wobble") 44 44 } ··· 46 46 47 47 pub type Wibble { 48 48 Wibble(inside: Wobble) 49 - Wimble(a: Int, b: Int) 49 + Dummy(a: Int, b: Int) 50 50 }
+6 -6
language-server/src/tests/snapshots/gleam_language_server__tests__action__generate_dynamic_decoder_does_not_produce_zero_values_for_types_from_other_packages.snap
··· 1 1 --- 2 2 source: language-server/src/tests/action.rs 3 - expression: "\nimport wibble.{type Wibble}\n\npub type Wobble {\n Wobble(value: Wibble)\n Wimble(a: Int, b: Int)\n}\n " 3 + expression: "\nimport wibble.{type Wibble}\n\npub type Wobble {\n Wobble(value: Wibble)\n Dummy(a: Int, b: Int)\n}\n " 4 4 --- 5 5 ----- BEFORE ACTION 6 6 ··· 10 10 ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 11 11 Wobble(value: Wibble) 12 12 ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 13 - Wimble(a: Int, b: Int) 14 - ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 13 + Dummy(a: Int, b: Int) 14 + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 15 15 } 16 16 17 17 ··· 24 24 25 25 pub type Wobble { 26 26 Wobble(value: Wibble) 27 - Wimble(a: Int, b: Int) 27 + Dummy(a: Int, b: Int) 28 28 } 29 29 30 30 fn wobble_decoder() -> decode.Decoder(Wobble) { ··· 34 34 use value <- decode.field("value", todo as "Decoder for Wibble") 35 35 decode.success(Wobble(value:)) 36 36 } 37 - "wimble" -> { 37 + "dummy" -> { 38 38 use a <- decode.field("a", decode.int) 39 39 use b <- decode.field("b", decode.int) 40 - decode.success(Wimble(a:, b:)) 40 + decode.success(Dummy(a:, b:)) 41 41 } 42 42 _ -> decode.failure(todo as "Zero value for Wobble", "Wobble") 43 43 }
+6 -6
language-server/src/tests/snapshots/gleam_language_server__tests__action__generate_dynamic_decoder_produces_zero_values_for_prelude_and_stdlib_types.snap
··· 1 1 --- 2 2 source: language-server/src/tests/action.rs 3 - expression: "\nimport gleam/option\nimport gleam/dict\n\npub type Wobble {\n Wobble(\n bit_array: BitArray,\n int: Int,\n float: Float,\n bool: Bool,\n list: List(Int),\n string: String,\n nil: Nil,\n option: option.Option(String),\n dict: dict.Dict(Int, Bool),\n )\n Wimble(\n a: Int,\n b: Int,\n c: Int,\n d: Int,\n e: Int,\n f: Int,\n g: Int,\n h: Int,\n i: Int,\n j: Int,\n )\n}\n " 3 + expression: "\nimport gleam/option\nimport gleam/dict\n\npub type Wobble {\n Wobble(\n bit_array: BitArray,\n int: Int,\n float: Float,\n bool: Bool,\n list: List(Int),\n string: String,\n nil: Nil,\n option: option.Option(String),\n dict: dict.Dict(Int, Bool),\n )\n Dummy(\n a: Int,\n b: Int,\n c: Int,\n d: Int,\n e: Int,\n f: Int,\n g: Int,\n h: Int,\n i: Int,\n j: Int,\n )\n}\n " 4 4 --- 5 5 ----- BEFORE ACTION 6 6 ··· 31 31 ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 32 32 ) 33 33 ▔▔▔ 34 - Wimble( 35 - ▔▔▔▔▔▔▔▔▔ 34 + Dummy( 35 + ▔▔▔▔▔▔▔▔ 36 36 a: Int, 37 37 ▔▔▔▔▔▔▔▔▔▔▔ 38 38 b: Int, ··· 78 78 option: option.Option(String), 79 79 dict: dict.Dict(Int, Bool), 80 80 ) 81 - Wimble( 81 + Dummy( 82 82 a: Int, 83 83 b: Int, 84 84 c: Int, ··· 107 107 use dict <- decode.field("dict", decode.dict(decode.int, decode.bool)) 108 108 decode.success(Wobble(bit_array:, int:, float:, bool:, list:, string:, nil:, option:, dict:)) 109 109 } 110 - "wimble" -> { 110 + "dummy" -> { 111 111 use a <- decode.field("a", decode.int) 112 112 use b <- decode.field("b", decode.int) 113 113 use c <- decode.field("c", decode.int) ··· 118 118 use h <- decode.field("h", decode.int) 119 119 use i <- decode.field("i", decode.int) 120 120 use j <- decode.field("j", decode.int) 121 - decode.success(Wimble(a:, b:, c:, d:, e:, f:, g:, h:, i:, j:)) 121 + decode.success(Dummy(a:, b:, c:, d:, e:, f:, g:, h:, i:, j:)) 122 122 } 123 123 _ -> decode.failure(Wobble(bit_array: <<>>, int: 0, float: 0.0, bool: False, list: [], string: "", nil: Nil, option: option.None, dict: dict.new()), "Wobble") 124 124 }
+6 -6
language-server/src/tests/snapshots/gleam_language_server__tests__action__generate_dynamic_decoder_produces_zero_values_for_user_defined_type_in_the_same_package_1.snap
··· 1 1 --- 2 2 source: language-server/src/tests/action.rs 3 - expression: "\nimport wibble.{type Wibble}\n\npub type Wobble {\n Wobble(value: Wibble)\n Wimble(a: Int, b: Int)\n}\n " 3 + expression: "\nimport wibble.{type Wibble}\n\npub type Wobble {\n Wobble(value: Wibble)\n Dummy(a: Int, b: Int)\n}\n " 4 4 --- 5 5 ----- BEFORE ACTION 6 6 ··· 10 10 ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 11 11 Wobble(value: Wibble) 12 12 ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 13 - Wimble(a: Int, b: Int) 14 - ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 13 + Dummy(a: Int, b: Int) 14 + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 15 15 } 16 16 17 17 ··· 24 24 25 25 pub type Wobble { 26 26 Wobble(value: Wibble) 27 - Wimble(a: Int, b: Int) 27 + Dummy(a: Int, b: Int) 28 28 } 29 29 30 30 fn wobble_decoder() -> decode.Decoder(Wobble) { ··· 34 34 use value <- decode.field("value", todo as "Decoder for Wibble") 35 35 decode.success(Wobble(value:)) 36 36 } 37 - "wimble" -> { 37 + "dummy" -> { 38 38 use a <- decode.field("a", decode.int) 39 39 use b <- decode.field("b", decode.int) 40 - decode.success(Wimble(a:, b:)) 40 + decode.success(Dummy(a:, b:)) 41 41 } 42 42 _ -> decode.failure(Wobble(value: wibble.Wibble), "Wobble") 43 43 }
+10 -9
language-server/src/tests/snapshots/gleam_language_server__tests__action__generate_dynamic_decoder_produces_zero_values_for_user_defined_type_in_the_same_package_2.snap
··· 1 1 --- 2 2 source: language-server/src/tests/action.rs 3 - expression: "\nimport wibble.{type Wibble}\n\npub type Wobble {\n Wobble(value: Wibble)\n Wimble(a: Int, b: Int)\n}\n " 3 + expression: "\nimport internal/wibble.{type Wibble}\n\npub type Wobble {\n Wobble(value: Wibble)\n Dummy(a: Int, b: Int)\n}\n " 4 4 --- 5 5 ----- BEFORE ACTION 6 6 7 - import wibble.{type Wibble} 7 + import internal/wibble.{type Wibble} 8 8 9 9 pub type Wobble { 10 10 ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 11 11 Wobble(value: Wibble) 12 12 ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 13 - Wimble(a: Int, b: Int) 14 - ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 13 + Dummy(a: Int, b: Int) 14 + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 15 15 } 16 16 17 17 ··· 19 19 20 20 ----- AFTER ACTION 21 21 22 + import internal/nested_wibble 22 23 import gleam/dynamic/decode 23 - import wibble.{type Wibble} 24 + import internal/wibble.{type Wibble} 24 25 25 26 pub type Wobble { 26 27 Wobble(value: Wibble) 27 - Wimble(a: Int, b: Int) 28 + Dummy(a: Int, b: Int) 28 29 } 29 30 30 31 fn wobble_decoder() -> decode.Decoder(Wobble) { ··· 34 35 use value <- decode.field("value", todo as "Decoder for Wibble") 35 36 decode.success(Wobble(value:)) 36 37 } 37 - "wimble" -> { 38 + "dummy" -> { 38 39 use a <- decode.field("a", decode.int) 39 40 use b <- decode.field("b", decode.int) 40 - decode.success(Wimble(a:, b:)) 41 + decode.success(Dummy(a:, b:)) 41 42 } 42 - _ -> decode.failure(Wobble(value: wibble.Wibble(value: wibble.NestedWibble)), "Wobble") 43 + _ -> decode.failure(Wobble(value: wibble.Wibble(value: nested_wibble.NestedWibble)), "Wobble") 43 44 } 44 45 }
+6 -6
language-server/src/tests/snapshots/gleam_language_server__tests__action__generate_dynamic_decoder_produces_zero_values_for_user_defined_type_in_the_same_package_3.snap
··· 1 1 --- 2 2 source: language-server/src/tests/action.rs 3 - expression: "\nimport wibble.{type Wibble}\n\npub type Wobble {\n Wobble(value: Wibble)\n Wimble(a: Int, b: Int)\n}\n " 3 + expression: "\nimport wibble.{type Wibble}\n\npub type Wobble {\n Wobble(value: Wibble)\n Dummy(a: Int, b: Int)\n}\n " 4 4 --- 5 5 ----- BEFORE ACTION 6 6 ··· 10 10 ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 11 11 Wobble(value: Wibble) 12 12 ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 13 - Wimble(a: Int, b: Int) 14 - ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 13 + Dummy(a: Int, b: Int) 14 + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 15 15 } 16 16 17 17 ··· 25 25 26 26 pub type Wobble { 27 27 Wobble(value: Wibble) 28 - Wimble(a: Int, b: Int) 28 + Dummy(a: Int, b: Int) 29 29 } 30 30 31 31 fn wobble_decoder() -> decode.Decoder(Wobble) { ··· 35 35 use value <- decode.field("value", todo as "Decoder for Wibble") 36 36 decode.success(Wobble(value:)) 37 37 } 38 - "wimble" -> { 38 + "dummy" -> { 39 39 use a <- decode.field("a", decode.int) 40 40 use b <- decode.field("b", decode.int) 41 - decode.success(Wimble(a:, b:)) 41 + decode.success(Dummy(a:, b:)) 42 42 } 43 43 _ -> decode.failure(Wobble(value: wibble.Wibble(map: dict.new())), "Wobble") 44 44 }