A Gleam codegen library in Gleam

Use Birdie for testing

Signed-off-by: Naomi Roberts <mia@naomieow.xyz>

lesbian.skin cb36ca83 0c5e1794

verified
0/0
Waiting for spindle ...
+13
birdie_snapshots/float_addition.accepted
··· 1 + --- 2 + version: 1.4.0 3 + title: Float Addition 4 + file: ./test/stare_test.gleam 5 + test_name: float_addition_test 6 + --- 7 + import gleam/float 8 + import gleam/io 9 + 10 + pub fn main() { 11 + io.println(float.to_string(1.1 +. 2.2)) 12 + } 13 +
+12
birdie_snapshots/hello_world.accepted
··· 1 + --- 2 + version: 1.4.0 3 + title: Hello World 4 + file: ./test/stare_test.gleam 5 + test_name: generate_hello_world_test 6 + --- 7 + import gleam/io 8 + 9 + pub fn main() -> Nil { 10 + io.println("Hello World!") 11 + } 12 +
+13
birdie_snapshots/int_addition.accepted
··· 1 + --- 2 + version: 1.4.0 3 + title: Int Addition 4 + file: ./test/stare_test.gleam 5 + test_name: integer_addition_test 6 + --- 7 + import gleam/int 8 + import gleam/io 9 + 10 + pub fn main() { 11 + io.println(int.to_string(1 + 2)) 12 + } 13 +
+1
gleam.toml
··· 19 19 20 20 [dev-dependencies] 21 21 gleeunit = ">= 1.0.0 and < 2.0.0" 22 + birdie = ">= 1.4.0 and < 2.0.0"
+15
manifest.toml
··· 2 2 # You typically do not need to edit this file 3 3 4 4 packages = [ 5 + { name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" }, 6 + { name = "birdie", version = "1.4.0", build_tools = ["gleam"], requirements = ["argv", "edit_distance", "filepath", "glance", "gleam_community_ansi", "gleam_stdlib", "justin", "rank", "simplifile", "term_size", "trie_again"], otp_app = "birdie", source = "hex", outer_checksum = "28F6E2F195EFB637FBBE001DD67CF34B511C5BED8921956879D29928470CFAE2" }, 7 + { name = "edit_distance", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "edit_distance", source = "hex", outer_checksum = "A1E485C69A70210223E46E63985FA1008B8B2DDA9848B7897469171B29020C05" }, 5 8 { name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" }, 9 + { name = "glance", version = "5.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "glexer"], otp_app = "glance", source = "hex", outer_checksum = "7F216D97935465FF4AC46699CD1C3E0FB19CB678B002E4ACAFCE256E96312F14" }, 10 + { name = "gleam_community_ansi", version = "1.4.3", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_regexp", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "8A62AE9CC6EA65BEA630D95016D6C07E4F9973565FA3D0DE68DC4200D8E0DD27" }, 11 + { name = "gleam_community_colour", version = "2.0.2", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "E34DD2C896AC3792151EDA939DA435FF3B69922F33415ED3C4406C932FBE9634" }, 12 + { name = "gleam_json", version = "3.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "874FA3C3BB6E22DD2BB111966BD40B3759E9094E05257899A7C08F5DE77EC049" }, 13 + { name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" }, 6 14 { name = "gleam_stdlib", version = "0.63.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5E216C7D5E8BE22359C9D7DAA2CFBD66039BC12565542F34CD033C5BB57071ED" }, 7 15 { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" }, 16 + { name = "glexer", version = "2.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "splitter"], otp_app = "glexer", source = "hex", outer_checksum = "40A1FB0919FA080AD6C5809B4C7DBA545841CAAC8168FACDFA0B0667C22475CC" }, 17 + { name = "justin", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "justin", source = "hex", outer_checksum = "7FA0C6DB78640C6DC5FBFD59BF3456009F3F8B485BF6825E97E1EB44E9A1E2CD" }, 18 + { name = "rank", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "rank", source = "hex", outer_checksum = "5660E361F0E49CBB714CC57CC4C89C63415D8986F05B2DA0C719D5642FAD91C9" }, 8 19 { name = "shellout", version = "1.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "1BDC03438FEB97A6AF3E396F4ABEB32BECF20DF2452EC9A8C0ACEB7BDDF70B14" }, 9 20 { name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" }, 21 + { name = "splitter", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "splitter", source = "hex", outer_checksum = "05564A381580395DCDEFF4F88A64B021E8DAFA6540AE99B4623962F52976AA9D" }, 22 + { name = "term_size", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "term_size", source = "hex", outer_checksum = "D00BD2BC8FB3EBB7E6AE076F3F1FF2AC9D5ED1805F004D0896C784D06C6645F1" }, 23 + { name = "trie_again", version = "1.1.3", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "trie_again", source = "hex", outer_checksum = "365FE609649F3A098D1D7FC7EA5222EE422F0B3745587BF2AB03352357CA70BB" }, 10 24 ] 11 25 12 26 [requirements] 27 + birdie = { version = ">= 1.4.0 and < 2.0.0" } 13 28 gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" } 14 29 gleeunit = { version = ">= 1.0.0 and < 2.0.0" } 15 30 shellout = { version = ">= 1.7.0 and < 2.0.0" }
+19 -40
test/stare_test.gleam
··· 1 + import birdie 1 2 import gleam/option.{None, Some} 2 3 import gleeunit 3 4 import stare ··· 49 50 ), 50 51 ], 51 52 ) 52 - let assert Ok(code) = 53 - module 54 - |> stare.generate() 55 - |> stare.format() 56 53 57 - let file = 58 - "import gleam/int 59 - import gleam/io 60 - 61 - pub fn main() { 62 - io.println(int.to_string(1 + 2)) 63 - } 64 - " 65 - 66 - assert file == code 54 + module 55 + |> stare.generate() 56 + |> stare.format() 57 + |> assert_ok() 58 + |> birdie.snap("Int Addition") 67 59 } 68 60 69 61 pub fn float_addition_test() { ··· 107 99 ), 108 100 ], 109 101 ) 110 - let assert Ok(code) = 111 - module 112 - |> stare.generate() 113 - |> stare.format() 114 102 115 - let file = 116 - "import gleam/float 117 - import gleam/io 118 - 119 - pub fn main() { 120 - io.println(float.to_string(1.1 +. 2.2)) 121 - } 122 - " 123 - 124 - assert file == code 103 + module 104 + |> stare.generate() 105 + |> stare.format() 106 + |> assert_ok() 107 + |> birdie.snap("Float Addition") 125 108 } 126 109 127 110 pub fn generate_hello_world_test() { ··· 153 136 ], 154 137 ) 155 138 156 - let assert Ok(code) = 157 - module 158 - |> stare.generate() 159 - |> stare.format() 160 - 161 - let file = 162 - "import gleam/io 163 - 164 - pub fn main() -> Nil { 165 - io.println(\"Hello World!\") 139 + module 140 + |> stare.generate() 141 + |> stare.format() 142 + |> assert_ok() 143 + |> birdie.snap("Hello World") 166 144 } 167 - " 168 145 169 - assert file == code 146 + fn assert_ok(value: Result(a, b)) -> a { 147 + let assert Ok(res) = value 148 + res 170 149 }