@@ -5,6 +5,7 @@ const oniguruma = require('vscode-oniguruma')
5
5
const { expect } = require ( 'chai' )
6
6
7
7
const GRAMMAR_PATH = path . join ( __dirname , '../grammars/julia_vscode.json' )
8
+ const GRAMMAR_CONSOLE_PATH = path . join ( __dirname , '../grammars/julia-console.json' )
8
9
9
10
/**
10
11
* Utility to read a file as a promise
@@ -30,6 +31,9 @@ const registry = new vsctm.Registry({
30
31
if ( scopeName === 'source.julia' ) {
31
32
return readFile ( GRAMMAR_PATH ) . then ( data => vsctm . parseRawGrammar ( data . toString ( ) , GRAMMAR_PATH ) )
32
33
}
34
+ if ( scopeName === 'source.julia.console' ) {
35
+ return readFile ( GRAMMAR_CONSOLE_PATH ) . then ( data => vsctm . parseRawGrammar ( data . toString ( ) , GRAMMAR_PATH ) )
36
+ }
33
37
return null
34
38
}
35
39
} )
@@ -3734,3 +3738,80 @@ describe('Julia grammar', function () {
3734
3738
] )
3735
3739
} )
3736
3740
} )
3741
+
3742
+ describe ( 'Julia-Console' , function ( ) {
3743
+ let grammar
3744
+ before ( async function ( ) {
3745
+ grammar = await registry . loadGrammar ( 'source.julia.console' )
3746
+ } )
3747
+ it ( 'parses the grammar' , function ( ) {
3748
+ expect ( grammar ) . to . be . a ( 'object' )
3749
+ } )
3750
+ it ( "should highlight multi-line expressions" , function ( ) {
3751
+ const src = `julia> true
3752
+ true
3753
+
3754
+ julia> begin
3755
+ end
3756
+ ` ;
3757
+ const tokens = tokenize ( grammar , src )
3758
+ compareTokens ( tokens , [
3759
+ {
3760
+ value : "julia>" ,
3761
+ scopes : [ "source.julia.console" , "punctuation.separator.prompt.julia.console" ] ,
3762
+ } ,
3763
+ { scopes : [ 'source.julia.console' ] , value : ' ' } ,
3764
+ {
3765
+ value : "true" ,
3766
+ scopes : [ "source.julia.console" , "constant.language.julia" ] ,
3767
+ } ,
3768
+ { scopes : [ 'source.julia.console' ] , value : '\ntrue\n\n' } ,
3769
+ {
3770
+ value : "julia>" ,
3771
+ scopes : [ "source.julia.console" , "punctuation.separator.prompt.julia.console" ] ,
3772
+ } ,
3773
+ { scopes : [ 'source.julia.console' ] , value : ' ' } ,
3774
+ {
3775
+ value : "begin" ,
3776
+ scopes :[ "source.julia.console" , "keyword.control.julia" ] ,
3777
+ } ,
3778
+ { scopes : [ "source.julia.console" ] , value : "\n " } ,
3779
+ {
3780
+ value : "end" ,
3781
+ scopes : [ "source.julia.console" , "keyword.control.end.julia" ] ,
3782
+ } ,
3783
+ ] )
3784
+ } )
3785
+
3786
+ it ( "should highlight help prompts" , function ( ) {
3787
+ const src = "help?> begin"
3788
+ const tokens = tokenize ( grammar , src )
3789
+ compareTokens ( tokens , [
3790
+ {
3791
+ scopes : [
3792
+ 'source.julia.console' ,
3793
+ 'punctuation.separator.prompt.help.julia.console'
3794
+ ] ,
3795
+ value : 'help?>'
3796
+ } ,
3797
+ { scopes : [ 'source.julia.console' ] , value : ' ' } ,
3798
+ { scopes : [ 'source.julia.console' , 'keyword.control.julia' ] , value : 'begin' }
3799
+ ] )
3800
+ } )
3801
+
3802
+ it ( "should highlight shell prompts" , function ( ) {
3803
+ const src = "shell> echo \"hello\""
3804
+ const tokens = tokenize ( grammar , src )
3805
+ compareTokens ( tokens , [
3806
+ {
3807
+ scopes : [
3808
+ 'source.julia.console' ,
3809
+ 'punctuation.separator.prompt.shell.julia.console'
3810
+ ] ,
3811
+ value : 'shell>'
3812
+ } ,
3813
+ { scopes : [ 'source.julia.console' ] , value : ' ' } ,
3814
+ { scopes : [ 'source.julia.console' ] , value : 'echo "hello"' }
3815
+ ] )
3816
+ } )
3817
+ } )
0 commit comments