@@ -25,8 +25,15 @@ function tokenStyleAsString(ts: TokenStyle | undefined | null) {
2525 return ts ? `${ ts . foreground ? ts . foreground . toString ( ) : 'no-foreground' } -${ ts . styles ? ts . styles : 'no-styles' } ` : 'tokenstyle-undefined' ;
2626}
2727
28- function assertTokenStyle ( expected : TokenStyle | undefined | null , actual : TokenStyle | undefined | null , message ?: string ) {
29- assert . equal ( tokenStyleAsString ( expected ) , tokenStyleAsString ( actual ) , message ) ;
28+ function assertTokenStyle ( actual : TokenStyle | undefined | null , expected : TokenStyle | undefined | null , message ?: string ) {
29+ assert . equal ( tokenStyleAsString ( actual ) , tokenStyleAsString ( expected ) , message ) ;
30+ }
31+
32+ function assertTokenStyles ( themeData : ColorThemeData , expected : { [ tokenStyleId : string ] : TokenStyle } ) {
33+ for ( let tokenStyleId in expected ) {
34+ const tokenStyle = themeData . getTokenStyle ( tokenStyleId ) ;
35+ assertTokenStyle ( tokenStyle , expected [ tokenStyleId ] , tokenStyleId ) ;
36+ }
3037}
3138
3239
@@ -45,28 +52,115 @@ suite('Themes - TokenStyleResolving', () => {
4552
4653 assert . equal ( themeData . isLoaded , true ) ;
4754
48- let tokenStyle ;
55+ assertTokenStyles ( themeData , {
56+ [ comments ] : ts ( '#75715E' , 0 ) ,
57+ [ variables ] : ts ( '#F8F8F2' , 0 ) ,
58+ [ types ] : ts ( '#A6E22E' , TokenStyleBits . UNDERLINE ) ,
59+ [ functions ] : ts ( '#A6E22E' , 0 ) ,
60+ [ strings ] : ts ( '#E6DB74' , 0 ) ,
61+ [ numbers ] : ts ( '#AE81FF' , 0 ) ,
62+ [ keywords ] : ts ( '#F92672' , 0 )
63+ } ) ;
64+
65+ } ) ;
66+
67+ test ( 'color defaults - dark+' , async ( ) => {
68+ const themeData = ColorThemeData . createUnloadedTheme ( 'foo' ) ;
69+ const themeLocation = getPathFromAmdModule ( require , '../../../../../../../extensions/theme-defaults/themes/dark_plus.json' ) ;
70+ themeData . location = URI . file ( themeLocation ) ;
71+ await themeData . ensureLoaded ( fileService ) ;
72+
73+ assert . equal ( themeData . isLoaded , true ) ;
74+
75+ assertTokenStyles ( themeData , {
76+ [ comments ] : ts ( '#6A9955' , 0 ) ,
77+ [ variables ] : ts ( '#9CDCFE' , 0 ) ,
78+ [ types ] : ts ( '#4EC9B0' , 0 ) ,
79+ [ functions ] : ts ( '#DCDCAA' , 0 ) ,
80+ [ strings ] : ts ( '#CE9178' , 0 ) ,
81+ [ numbers ] : ts ( '#B5CEA8' , 0 ) ,
82+ [ keywords ] : ts ( '#C586C0' , 0 )
83+ } ) ;
84+
85+ } ) ;
86+
87+ test ( 'color defaults - light vs' , async ( ) => {
88+ const themeData = ColorThemeData . createUnloadedTheme ( 'foo' ) ;
89+ const themeLocation = getPathFromAmdModule ( require , '../../../../../../../extensions/theme-defaults/themes/light_vs.json' ) ;
90+ themeData . location = URI . file ( themeLocation ) ;
91+ await themeData . ensureLoaded ( fileService ) ;
92+
93+ assert . equal ( themeData . isLoaded , true ) ;
94+
95+ assertTokenStyles ( themeData , {
96+ [ comments ] : ts ( '#008000' , 0 ) ,
97+ [ variables ] : ts ( '#000000' , 0 ) ,
98+ [ types ] : ts ( '#000000' , 0 ) ,
99+ [ functions ] : ts ( '#000000' , 0 ) ,
100+ [ strings ] : ts ( '#a31515' , 0 ) ,
101+ [ numbers ] : ts ( '#09885a' , 0 ) ,
102+ [ keywords ] : ts ( '#0000ff' , 0 )
103+ } ) ;
104+
105+ } ) ;
49106
50- tokenStyle = themeData . getTokenStyle ( comments ) ;
51- assertTokenStyle ( tokenStyle , ts ( '#75715E' , 0 ) ) ;
107+ test ( 'color defaults - hc' , async ( ) => {
108+ const themeData = ColorThemeData . createUnloadedTheme ( 'foo' ) ;
109+ const themeLocation = getPathFromAmdModule ( require , '../../../../../../../extensions/theme-defaults/themes/hc_black.json' ) ;
110+ themeData . location = URI . file ( themeLocation ) ;
111+ await themeData . ensureLoaded ( fileService ) ;
52112
53- tokenStyle = themeData . getTokenStyle ( variables ) ;
54- assertTokenStyle ( tokenStyle , ts ( '#F8F8F2' , 0 ) ) ;
113+ assert . equal ( themeData . isLoaded , true ) ;
55114
56- tokenStyle = themeData . getTokenStyle ( types ) ;
57- assertTokenStyle ( tokenStyle , ts ( '#A6E22E' , TokenStyleBits . UNDERLINE ) ) ;
115+ assertTokenStyles ( themeData , {
116+ [ comments ] : ts ( '#7ca668' , 0 ) ,
117+ [ variables ] : ts ( '#9CDCFE' , 0 ) ,
118+ [ types ] : ts ( '#4EC9B0' , 0 ) ,
119+ [ functions ] : ts ( '#DCDCAA' , 0 ) ,
120+ [ strings ] : ts ( '#ce9178' , 0 ) ,
121+ [ numbers ] : ts ( '#b5cea8' , 0 ) ,
122+ [ keywords ] : ts ( '#C586C0' , 0 )
123+ } ) ;
58124
59- tokenStyle = themeData . getTokenStyle ( functions ) ;
60- assertTokenStyle ( tokenStyle , ts ( '#A6E22E' , 0 ) ) ;
125+ } ) ;
61126
62- tokenStyle = themeData . getTokenStyle ( strings ) ;
63- assertTokenStyle ( tokenStyle , ts ( '#E6DB74' , 0 ) ) ;
127+ test ( 'color defaults - kimbie dark' , async ( ) => {
128+ const themeData = ColorThemeData . createUnloadedTheme ( 'foo' ) ;
129+ const themeLocation = getPathFromAmdModule ( require , '../../../../../../../extensions/theme-kimbie-dark/themes/kimbie-dark-color-theme.json' ) ;
130+ themeData . location = URI . file ( themeLocation ) ;
131+ await themeData . ensureLoaded ( fileService ) ;
64132
65- tokenStyle = themeData . getTokenStyle ( numbers ) ;
66- assertTokenStyle ( tokenStyle , ts ( '#AE81FF' , 0 ) ) ;
133+ assert . equal ( themeData . isLoaded , true ) ;
67134
68- tokenStyle = themeData . getTokenStyle ( keywords ) ;
69- assertTokenStyle ( tokenStyle , ts ( '#F92672' , 0 ) ) ;
135+ assertTokenStyles ( themeData , {
136+ [ comments ] : ts ( '#a57a4c' , 0 ) ,
137+ [ variables ] : ts ( '#dc3958' , 0 ) ,
138+ [ types ] : ts ( '#f06431' , 0 ) ,
139+ [ functions ] : ts ( '#8ab1b0' , 0 ) ,
140+ [ strings ] : ts ( '#889b4a' , 0 ) ,
141+ [ numbers ] : ts ( '#f79a32' , 0 ) ,
142+ [ keywords ] : ts ( '#98676a' , 0 )
143+ } ) ;
144+
145+ } ) ;
146+
147+ test ( 'color defaults - abyss' , async ( ) => {
148+ const themeData = ColorThemeData . createUnloadedTheme ( 'foo' ) ;
149+ const themeLocation = getPathFromAmdModule ( require , '../../../../../../../extensions/theme-abyss/themes/abyss-color-theme.json' ) ;
150+ themeData . location = URI . file ( themeLocation ) ;
151+ await themeData . ensureLoaded ( fileService ) ;
152+
153+ assert . equal ( themeData . isLoaded , true ) ;
154+
155+ assertTokenStyles ( themeData , {
156+ [ comments ] : ts ( '#384887' , 0 ) ,
157+ [ variables ] : ts ( '#9966b8' , 0 ) ,
158+ [ types ] : ts ( '#f06431' , 0 ) ,
159+ [ functions ] : ts ( '#8ab1b0' , 0 ) ,
160+ [ strings ] : ts ( '#22aa44' , 0 ) ,
161+ [ numbers ] : ts ( '#f280d0' , 0 ) ,
162+ [ keywords ] : ts ( '#98676a' , 0 )
163+ } ) ;
70164
71165 } ) ;
72166
@@ -83,7 +177,7 @@ suite('Themes - TokenStyleResolving', () => {
83177 }
84178 } ,
85179 {
86- scope : 'keyword' ,
180+ scope : 'keyword.operator ' ,
87181 settings : {
88182 fontStyle : 'italic bold underline' ,
89183 foreground : '#F92672'
@@ -119,9 +213,18 @@ suite('Themes - TokenStyleResolving', () => {
119213 tokenStyle = themeData . findTokenStyleForScope ( [ 'variable' ] ) ;
120214 assertTokenStyle ( tokenStyle , ts ( '#F8F8F2' , 0 ) , 'variable' ) ;
121215
122- tokenStyle = themeData . findTokenStyleForScope ( [ 'keyword' ] ) ;
216+ tokenStyle = themeData . findTokenStyleForScope ( [ 'keyword.operator ' ] ) ;
123217 assertTokenStyle ( tokenStyle , ts ( '#F92672' , TokenStyleBits . ITALIC | TokenStyleBits . BOLD | TokenStyleBits . UNDERLINE ) , 'keyword' ) ;
124218
219+ tokenStyle = themeData . findTokenStyleForScope ( [ 'keyword' ] ) ;
220+ assertTokenStyle ( tokenStyle , undefined , 'keyword' ) ;
221+
222+ tokenStyle = themeData . findTokenStyleForScope ( [ 'keyword.operator' ] ) ;
223+ assertTokenStyle ( tokenStyle , ts ( '#F92672' , TokenStyleBits . ITALIC | TokenStyleBits . BOLD | TokenStyleBits . UNDERLINE ) , 'keyword.operator' ) ;
224+
225+ tokenStyle = themeData . findTokenStyleForScope ( [ 'keyword.operators' ] ) ;
226+ assertTokenStyle ( tokenStyle , undefined , 'keyword.operators' ) ;
227+
125228 tokenStyle = themeData . findTokenStyleForScope ( [ 'storage' ] ) ;
126229 assertTokenStyle ( tokenStyle , ts ( '#F92672' , TokenStyleBits . ITALIC ) , 'storage' ) ;
127230
0 commit comments