123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446 |
- /*---------------------------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
- 'use strict';
- import { testTokenization } from '../test/testRunner';
- testTokenization('fsharp', [
- // comments - single line
- [{
- line: '// one line comment',
- tokens: [
- { startIndex: 0, type: 'comment.fs' }
- ]
- }],
- [{
- line: '//',
- tokens: [
- { startIndex: 0, type: 'comment.fs' }
- ]
- }],
- [{
- line: ' // a comment',
- tokens: [
- { startIndex: 0, type: '' },
- { startIndex: 4, type: 'comment.fs' }
- ]
- }],
- [{
- line: '// a comment',
- tokens: [
- { startIndex: 0, type: 'comment.fs' }
- ]
- }],
- [{
- line: '//sticky comment',
- tokens: [
- { startIndex: 0, type: 'comment.fs' }
- ]
- }],
- [{
- line: '/almost a comment',
- tokens: [
- { startIndex: 0, type: 'delimiter.fs' },
- { startIndex: 1, type: 'identifier.fs' },
- { startIndex: 7, type: '' },
- { startIndex: 8, type: 'identifier.fs' },
- { startIndex: 9, type: '' },
- { startIndex: 10, type: 'identifier.fs' }
- ]
- }],
- [{
- line: '(/*almost a comment',
- tokens: [
- { startIndex: 0, type: 'delimiter.parenthesis.fs' },
- { startIndex: 1, type: 'delimiter.fs' },
- { startIndex: 3, type: 'identifier.fs' },
- { startIndex: 9, type: '' },
- { startIndex: 10, type: 'identifier.fs' },
- { startIndex: 11, type: '' },
- { startIndex: 12, type: 'identifier.fs' }
- ]
- }],
- [{
- line: '1 / 2; (* comment',
- tokens: [
- { startIndex: 0, type: 'number.fs' },
- { startIndex: 1, type: '' },
- { startIndex: 2, type: 'delimiter.fs' },
- { startIndex: 3, type: '' },
- { startIndex: 4, type: 'number.fs' },
- { startIndex: 5, type: 'delimiter.fs' },
- { startIndex: 6, type: '' },
- { startIndex: 7, type: 'comment.fs' }
- ]
- }],
- [{
- line: 'let x = 1; // my comment // is a nice one',
- tokens: [
- { startIndex: 0, type: 'keyword.let.fs' },
- { startIndex: 3, type: '' },
- { startIndex: 4, type: 'identifier.fs' },
- { startIndex: 5, type: '' },
- { startIndex: 6, type: 'delimiter.fs' },
- { startIndex: 7, type: '' },
- { startIndex: 8, type: 'number.fs' },
- { startIndex: 9, type: 'delimiter.fs' },
- { startIndex: 10, type: '' },
- { startIndex: 11, type: 'comment.fs' }
- ]
- }],
- // Keywords
- [{
- line: 'namespace Application1',
- tokens: [
- { startIndex: 0, type: 'keyword.namespace.fs' },
- { startIndex: 9, type: '' },
- { startIndex: 10, type: 'identifier.fs' }
- ]
- }],
- [{
- line: 'type MyType',
- tokens: [
- { startIndex: 0, type: 'keyword.type.fs' },
- { startIndex: 4, type: '' },
- { startIndex: 5, type: 'identifier.fs' }
- ]
- }],
- [{
- line: 'module App =',
- tokens: [
- { startIndex: 0, type: 'keyword.module.fs' },
- { startIndex: 6, type: '' },
- { startIndex: 7, type: 'identifier.fs' },
- { startIndex: 10, type: '' },
- { startIndex: 11, type: 'delimiter.fs' }
- ]
- }],
- [{
- line: 'let AppName = "App1"',
- tokens: [
- { startIndex: 0, type: 'keyword.let.fs' },
- { startIndex: 3, type: '' },
- { startIndex: 4, type: 'identifier.fs' },
- { startIndex: 11, type: '' },
- { startIndex: 12, type: 'delimiter.fs' },
- { startIndex: 13, type: '' },
- { startIndex: 14, type: 'string.fs' }
- ]
- }],
- // Comments - range comment
- [{
- line: '(* a simple comment *)',
- tokens: [
- { startIndex: 0, type: 'comment.fs' }
- ]
- }],
- [{
- line: 'let x = (* a simple comment *) 1',
- tokens: [
- { startIndex: 0, type: 'keyword.let.fs' },
- { startIndex: 3, type: '' },
- { startIndex: 4, type: 'identifier.fs' },
- { startIndex: 5, type: '' },
- { startIndex: 6, type: 'delimiter.fs' },
- { startIndex: 7, type: '' },
- { startIndex: 8, type: 'comment.fs' },
- { startIndex: 30, type: '' },
- { startIndex: 31, type: 'number.fs' }
- ]
- }],
- [{
- line: 'x = (**)',
- tokens: [
- { startIndex: 0, type: 'identifier.fs' },
- { startIndex: 1, type: '' },
- { startIndex: 2, type: 'delimiter.fs' },
- { startIndex: 3, type: '' },
- { startIndex: 4, type: 'comment.fs' }
- ]
- }],
- [{
- line: 'x = (*)',
- tokens: [
- { startIndex: 0, type: 'identifier.fs' },
- { startIndex: 1, type: '' },
- { startIndex: 2, type: 'delimiter.fs' },
- { startIndex: 3, type: '' },
- { startIndex: 4, type: 'delimiter.parenthesis.fs' },
- { startIndex: 5, type: 'delimiter.fs' },
- { startIndex: 6, type: 'delimiter.parenthesis.fs' }
- ]
- }],
- // Numbers
- [{
- line: '0',
- tokens: [
- { startIndex: 0, type: 'number.fs' }
- ]
- }],
- [{
- line: '0x123',
- tokens: [
- { startIndex: 0, type: 'number.hex.fs' }
- ]
- }],
- [{
- line: '23.5',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '23.5e3',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '23.5E3',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '23.5F',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '23.5f',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '1.72E3F',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '1.72E3f',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '1.72e3F',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '1.72e3f',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '23.5M',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '23.5m',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '1.72E3M',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '1.72E3m',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '1.72e3M',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '1.72e3m',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }],
- [{
- line: '0+0',
- tokens: [
- { startIndex: 0, type: 'number.fs' },
- { startIndex: 1, type: 'delimiter.fs' },
- { startIndex: 2, type: 'number.fs' }
- ]
- }],
- [{
- line: '100+10',
- tokens: [
- { startIndex: 0, type: 'number.fs' },
- { startIndex: 3, type: 'delimiter.fs' },
- { startIndex: 4, type: 'number.fs' }
- ]
- }],
- [{
- line: '0 + 0',
- tokens: [
- { startIndex: 0, type: 'number.fs' },
- { startIndex: 1, type: '' },
- { startIndex: 2, type: 'delimiter.fs' },
- { startIndex: 3, type: '' },
- { startIndex: 4, type: 'number.fs' }
- ]
- }],
- [{
- line: '0b00000101',
- tokens: [
- { startIndex: 0, type: 'number.bin.fs' }
- ]
- }],
- [{
- line: '86y',
- tokens: [
- { startIndex: 0, type: 'number.fs' }
- ]
- }],
- [{
- line: '0b00000101y',
- tokens: [
- { startIndex: 0, type: 'number.bin.fs' }
- ]
- }],
- [{
- line: '86s',
- tokens: [
- { startIndex: 0, type: 'number.fs' }
- ]
- }],
- [{
- line: '86us',
- tokens: [
- { startIndex: 0, type: 'number.fs' }
- ]
- }],
- [{
- line: '86',
- tokens: [
- { startIndex: 0, type: 'number.fs' }
- ]
- }],
- [{
- line: '86l',
- tokens: [
- { startIndex: 0, type: 'number.fs' }
- ]
- }],
- [{
- line: '86u',
- tokens: [
- { startIndex: 0, type: 'number.fs' }
- ]
- }],
- [{
- line: '86ul',
- tokens: [
- { startIndex: 0, type: 'number.fs' }
- ]
- }],
- [{
- line: '0x00002D3Fn',
- tokens: [
- { startIndex: 0, type: 'number.hex.fs' }
- ]
- }],
- [{
- line: '0x00002D3Fun',
- tokens: [
- { startIndex: 0, type: 'number.hex.fs' }
- ]
- }],
- [{
- line: '86L',
- tokens: [
- { startIndex: 0, type: 'number.fs' }
- ]
- }],
- [{
- line: '86UL',
- tokens: [
- { startIndex: 0, type: 'number.fs' }
- ]
- }],
- [{
- line: '9999999999999999999999999999I',
- tokens: [
- { startIndex: 0, type: 'number.fs' }
- ]
- }],
- [{
- line: '0x00002D3FLF',
- tokens: [
- { startIndex: 0, type: 'number.float.fs' }
- ]
- }]
- ]);
|