Skip to content

Commit 6d5319c

Browse files
author
Dnld
committed
handles drop first method, adds appropriate tests
1 parent b73ff46 commit 6d5319c

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

tests/lexerTests/lexerTestsThirdMilestone.js

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4740,8 +4740,8 @@ describe('Lexer: Third Milestone', function() {
47404740

47414741
it('should handle the contains method', function () {
47424742
input = String.raw `var arr = [1,2,3,4,5]
4743-
var yes = arr.contains(4)
4744-
var no = arr.contains(6)`;
4743+
var yes = arr.contains(4)
4744+
var no = arr.contains(6)`;
47454745
output = [
47464746
{ type: "DECLARATION_KEYWORD", value: "var" },
47474747
{ type: "IDENTIFIER", value: "arr" },
@@ -4784,6 +4784,51 @@ describe('Lexer: Third Milestone', function() {
47844784
expect(lexer(input)).to.deep.equal(output);
47854785
});
47864786

4787+
it('should handle the drop first method', function () {
4788+
input = String.raw `var arr = [1,2,3,4,5]
4789+
var lessFirst = arr.dropFirst()
4790+
var lessFirstThree = arr.dropFirst(3)`;
4791+
output = [
4792+
{ type: "DECLARATION_KEYWORD", value: "var" },
4793+
{ type: "IDENTIFIER", value: "arr" },
4794+
{ type: "OPERATOR", value: "=" },
4795+
{ type: "ARRAY_START", value: "[" },
4796+
{ type: "NUMBER", value: "1" },
4797+
{ type: "PUNCTUATION", value: "," },
4798+
{ type: "NUMBER", value: "2" },
4799+
{ type: "PUNCTUATION", value: "," },
4800+
{ type: "NUMBER", value: "3" },
4801+
{ type: "PUNCTUATION", value: "," },
4802+
{ type: "NUMBER", value: "4" },
4803+
{ type: "PUNCTUATION", value: "," },
4804+
{ type: "NUMBER", value: "5" },
4805+
{ type: "ARRAY_END", value: "]" },
4806+
{ type: "TERMINATOR", value: "\\n"},
4807+
4808+
{ type: "DECLARATION_KEYWORD", value: "var" },
4809+
{ type: "IDENTIFIER", value: "lessFirst" },
4810+
{ type: "OPERATOR", value: "=" },
4811+
{ type: "IDENTIFIER", value: "arr" },
4812+
{ type: "DOT_SYNTAX", value: "." },
4813+
{ type: "NATIVE_METHOD", value: "dropFirst" },
4814+
{ type: "INVOCATION_START", value: "(" },
4815+
{ type: "INVOCATION_END", value: ")" },
4816+
{ type: "TERMINATOR", value: "\\n"},
4817+
4818+
{ type: "DECLARATION_KEYWORD", value: "var" },
4819+
{ type: "IDENTIFIER", value: "lessFirstThree" },
4820+
{ type: "OPERATOR", value: "=" },
4821+
{ type: "IDENTIFIER", value: "arr" },
4822+
{ type: "DOT_SYNTAX", value: "." },
4823+
{ type: "NATIVE_METHOD", value: "dropFirst" },
4824+
{ type: "INVOCATION_START", value: "(" },
4825+
{ type: "NUMBER", value: "3" },
4826+
{ type: "INVOCATION_END", value: ")" },
4827+
{ type: "TERMINATOR", value: "EOF" }
4828+
];
4829+
expect(lexer(input)).to.deep.equal(output);
4830+
});
4831+
47874832
});
47884833

47894834
});

transpiler/lexer/lexicalTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
'append': 'NATIVE_METHOD',
1717
'contains': 'NATIVE_METHOD',
1818
'distanceTo': 'NATIVE_METHOD',
19+
'dropFirst': 'NATIVE_METHOD',
1920
'hasPrefix': 'NATIVE_METHOD',
2021
'hasSuffix': 'NATIVE_METHOD',
2122
'insert': 'NATIVE_METHOD',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy