Skip to content

Commit

Permalink
Gleam support (#71)
Browse files Browse the repository at this point in the history
* Gleam support

Related to exercism/gleam#32 (comment)

* Oops, whitespace
  • Loading branch information
lpil authored Jan 27, 2023
1 parent 7865129 commit 78a2206
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/languages/gleam.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
!e
//\p
///\p
////\p
import
74 changes: 74 additions & 0 deletions test/languages/gleam_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
require "test_helper"

module SnippetExtractor
module Languages
class GleamTest < Minitest::Test
def test_full_example
code = <<~CODE
//// This is a file
//// With some comments in it
// And a blank line ⬆️
// It has some imports like this:
import gleam/erlang
import gleam/erlang/process.{Subject}
/// And then eventually the code
pub fn two_fer(name: String) -> String {
todo
}
CODE

expected = <<~CODE
pub fn two_fer(name: String) -> String {
todo
}
CODE

assert_equal expected, ExtractSnippet.(code, :gleam)
end

def test_extended_example
code = <<~CODE
//// This is a file
//// With some comments in it
// And a blank line ⬆️
// It has some imports like this:
import gleam/erlang
import gleam/erlang/process.{Subject}
/// And then eventually the code
pub fn two_fer(name: String) -> String {
todo// with comments
}
// Here is a comment
/// And a documentation comment
pub type TwoFer {
TwoFer(name: String)
}
const a = 1
const b = 1
const c = 1 // More, but this is over 10 lines so it wont appear
CODE

expected = <<~CODE
pub fn two_fer(name: String) -> String {
todo
}
pub type TwoFer {
TwoFer(name: String)
}
const a = 1
const b = 1
CODE

assert_equal expected, ExtractSnippet.(code, :gleam)
end
end
end
end

0 comments on commit 78a2206

Please sign in to comment.