Skip to content

Commit 553f4a2

Browse files
authored
Typescript added (exercism#16)
* Typescript added * Change class name of typescript test * Fixed typescript test * Fixing identation in typescript test
1 parent ba26b6f commit 553f4a2

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

lib/languages/typescript.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import
2+
/*
3+
/**
4+
*
5+
*/
6+
//
7+
from
8+
as

test/languages/typescript_test.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
require "test_helper"
2+
3+
module SnippetExtractor
4+
module Languages
5+
class TypescriptTest < Minitest::Test
6+
def test_full_example
7+
code = <<~CODE
8+
9+
// Skipping imports
10+
import * as example from 'example.js'
11+
import *
12+
as example
13+
from 'example.js'
14+
15+
import { get_data, get_data2 } from 'example.js
16+
17+
/// Saying things over
18+
/// multiple lines of code
19+
20+
/* Multiline comments */
21+
/**
22+
* Multiline comments 2
23+
*
24+
*/
25+
26+
let numberRegexp = /^[0-9]+$/;
27+
class ZipCodeValidator {
28+
isAcceptable(s: string) {
29+
return s.length === 5 && numberRegexp.test(s);
30+
}
31+
}
32+
export = ZipCodeValidator;
33+
CODE
34+
35+
expected = <<~CODE
36+
let numberRegexp = /^[0-9]+$/;
37+
class ZipCodeValidator {
38+
isAcceptable(s: string) {
39+
return s.length === 5 && numberRegexp.test(s);
40+
}
41+
}
42+
export = ZipCodeValidator;
43+
CODE
44+
45+
assert_equal expected, ExtractSnippet.(code, :typescript)
46+
end
47+
end
48+
end
49+
end

0 commit comments

Comments
 (0)