@@ -5,6 +5,7 @@ const oniguruma = require('vscode-oniguruma')
55const { expect } = require ( 'chai' )
66
77const GRAMMAR_PATH = path . join ( __dirname , '../grammars/julia_vscode.json' )
8+ const GRAMMAR_CONSOLE_PATH = path . join ( __dirname , '../grammars/julia-console.json' )
89
910/**
1011 * Utility to read a file as a promise
@@ -30,6 +31,9 @@ const registry = new vsctm.Registry({
3031 if ( scopeName === 'source.julia' ) {
3132 return readFile ( GRAMMAR_PATH ) . then ( data => vsctm . parseRawGrammar ( data . toString ( ) , GRAMMAR_PATH ) )
3233 }
34+ if ( scopeName === 'source.julia.console' ) {
35+ return readFile ( GRAMMAR_CONSOLE_PATH ) . then ( data => vsctm . parseRawGrammar ( data . toString ( ) , GRAMMAR_PATH ) )
36+ }
3337 return null
3438 }
3539} )
@@ -3681,3 +3685,48 @@ describe('Julia grammar', function () {
36813685 ] )
36823686 } )
36833687} )
3688+
3689+ describe ( 'Julia-Console' , function ( ) {
3690+ let grammar
3691+ before ( async function ( ) {
3692+ grammar = await registry . loadGrammar ( 'source.julia.console' )
3693+ } )
3694+ it ( 'parses the grammar' , function ( ) {
3695+ expect ( grammar ) . to . be . a ( 'object' )
3696+ } )
3697+ it ( "should highlight multi-line expressions" , function ( ) {
3698+ const src = `julia> true
3699+ true
3700+
3701+ julia> begin
3702+ end
3703+ ` ;
3704+ const tokens = tokenize ( grammar , src )
3705+ compareTokens ( tokens , [
3706+ {
3707+ value : "julia>" ,
3708+ scopes : [ "source.julia.console" , "punctuation.separator.prompt.julia.console" ] ,
3709+ } ,
3710+ { scopes : [ 'source.julia.console' ] , value : ' ' } ,
3711+ {
3712+ value : "true" ,
3713+ scopes : [ "source.julia.console" , "constant.language.julia" ] ,
3714+ } ,
3715+ { scopes : [ 'source.julia.console' ] , value : '\ntrue\n\n' } ,
3716+ {
3717+ value : "julia>" ,
3718+ scopes : [ "source.julia.console" , "punctuation.separator.prompt.julia.console" ] ,
3719+ } ,
3720+ { scopes : [ 'source.julia.console' ] , value : ' ' } ,
3721+ {
3722+ value : "begin" ,
3723+ scopes :[ "source.julia.console" , "keyword.control.julia" ] ,
3724+ } ,
3725+ { scopes : [ "source.julia.console" ] , value : "\n " } ,
3726+ {
3727+ value : "end" ,
3728+ scopes : [ "source.julia.console" , "keyword.control.end.julia" ] ,
3729+ } ,
3730+ ] )
3731+ } )
3732+ } )
0 commit comments