Skip to content

Commit b7cd812

Browse files
author
Dnld
committed
handles the min and max elements methods
1 parent 73522ad commit b7cd812

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

tests/lexerTests/lexerTestsThirdMilestone.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5180,6 +5180,50 @@ describe('Lexer: Third Milestone', function() {
51805180
expect(lexer(input)).to.deep.equal(output);
51815181
});
51825182

5183+
it('should handle the min and max element methods', function () {
5184+
input = String.raw `var arr = [1,2,3,4,5]
5185+
var one = arr.minElement()
5186+
var five = arr.maxElement()`;
5187+
output = [
5188+
{ type: "DECLARATION_KEYWORD", value: "var" },
5189+
{ type: "IDENTIFIER", value: "arr" },
5190+
{ type: "OPERATOR", value: "=" },
5191+
{ type: "ARRAY_START", value: "[" },
5192+
{ type: "NUMBER", value: "1" },
5193+
{ type: "PUNCTUATION", value: "," },
5194+
{ type: "NUMBER", value: "2" },
5195+
{ type: "PUNCTUATION", value: "," },
5196+
{ type: "NUMBER", value: "3" },
5197+
{ type: "PUNCTUATION", value: "," },
5198+
{ type: "NUMBER", value: "4" },
5199+
{ type: "PUNCTUATION", value: "," },
5200+
{ type: "NUMBER", value: "5" },
5201+
{ type: "ARRAY_END", value: "]" },
5202+
{ type: "TERMINATOR", value: "\\n"},
5203+
5204+
{ type: "DECLARATION_KEYWORD", value: "var" },
5205+
{ type: "IDENTIFIER", value: "one" },
5206+
{ type: "OPERATOR", value: "=" },
5207+
{ type: "IDENTIFIER", value: "arr" },
5208+
{ type: "DOT_SYNTAX", value: "." },
5209+
{ type: "NATIVE_METHOD", value: "minElement" },
5210+
{ type: "INVOCATION_START", value: "(" },
5211+
{ type: "INVOCATION_END", value: ")" },
5212+
{ type: "TERMINATOR", value: "\\n"},
5213+
5214+
{ type: "DECLARATION_KEYWORD", value: "var" },
5215+
{ type: "IDENTIFIER", value: "five" },
5216+
{ type: "OPERATOR", value: "=" },
5217+
{ type: "IDENTIFIER", value: "arr" },
5218+
{ type: "DOT_SYNTAX", value: "." },
5219+
{ type: "NATIVE_METHOD", value: "maxElement" },
5220+
{ type: "INVOCATION_START", value: "(" },
5221+
{ type: "INVOCATION_END", value: ")" },
5222+
{ type: "TERMINATOR", value: "EOF" }
5223+
];
5224+
expect(lexer(input)).to.deep.equal(output);
5225+
});
5226+
51835227
});
51845228

51855229
});

transpiler/lexer/lexicalTypes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ module.exports = {
2222
'hasSuffix': 'NATIVE_METHOD',
2323
'insert': 'NATIVE_METHOD',
2424
'insertContentsOf': 'NATIVE_METHOD',
25+
'maxElement': 'NATIVE_METHOD',
26+
'minElement': 'NATIVE_METHOD',
2527
'predecessor': 'NATIVE_METHOD',
2628
'popLast': 'NATIVE_METHOD',
2729
'print': '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