Skip to content

Commit 1e7b932

Browse files
committed
test
1 parent 5cf9c6a commit 1e7b932

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

packages/amazonq/test/unit/codewhisperer/util/runtimeLanguageContext.test.ts

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
*/
55

66
import assert from 'assert'
7-
import { resetCodeWhispererGlobalVariables } from 'aws-core-vscode/test'
7+
import { resetCodeWhispererGlobalVariables, toTextDocument } from 'aws-core-vscode/test'
88
import { runtimeLanguageContext, RuntimeLanguageContext, PlatformLanguageId } from 'aws-core-vscode/codewhisperer'
99
import * as codewhispererClient from 'aws-core-vscode/codewhisperer'
1010
import { CodewhispererLanguage } from 'aws-core-vscode/shared'
1111

1212
describe('runtimeLanguageContext', function () {
1313
const languageContext = new RuntimeLanguageContext()
1414

15-
describe('test isLanguageSupported', function () {
15+
describe('test isLanguageSupported with languageId as the argument', function () {
1616
const cases: [string, boolean][] = [
1717
['java', true],
1818
['javascript', true],
@@ -61,6 +61,61 @@ describe('runtimeLanguageContext', function () {
6161
assert.strictEqual(actual, expected)
6262
})
6363
})
64+
65+
describe('test isLanguageSupported with document as the argument', function () {
66+
const cases: [string, boolean][] = [
67+
['helloJava.java', true],
68+
['helloPython.py', true],
69+
['helloJavascript.js', true],
70+
['helloJsx.jsx', true],
71+
['helloTypescript.ts', true],
72+
['helloTsx.tsx', true],
73+
['helloCsharp.cs', true],
74+
['helloC.c', true],
75+
['helloC.h', true],
76+
['helloCpp.cpp', true],
77+
['helloCpp.cc', true],
78+
['helloGo.go', true],
79+
['helloKotlin.kt', true],
80+
['helloPhp.php', true],
81+
['helloRuby.rb', true],
82+
['helloRust.rs', true],
83+
['helloScala.scala', true],
84+
['helloShellscript.sh', true],
85+
['helloSql.sql', true],
86+
['helloSystemVerilog.svh', true],
87+
['helloSystemVerilog.sv', true],
88+
['helloSystemVerilog.vh', true],
89+
['helloDart.dart', true],
90+
['helloLua.lua', true],
91+
['helloLua.wlua', true],
92+
['helloSwift.swift', true],
93+
['helloVue.vue', true],
94+
['helloPowerShell.ps1', true],
95+
['helloPowerShell.psm1', true],
96+
['helloR.r', true],
97+
['helloJson.json', true],
98+
['helloYaml.yaml', true],
99+
['helloYaml.yml', true],
100+
['helloTf.tf', true],
101+
['helloPlaintext.txt', false],
102+
['helloHtml.html', false],
103+
['helloCss.css', false],
104+
['helloUnknown', false],
105+
['helloFoo.foo', false],
106+
]
107+
108+
cases.forEach((tuple) => {
109+
const fileName = tuple[0]
110+
const expected = tuple[1]
111+
112+
it(`pass document ${fileName} as argument should first try determine by languageId then file extensions`, async function () {
113+
const doc = await toTextDocument('', fileName)
114+
const actual = languageContext.isLanguageSupported(doc)
115+
assert.strictEqual(actual, expected)
116+
})
117+
})
118+
})
64119
})
65120

66121
describe('test getLanguageContext', function () {

packages/core/src/codewhisperer/util/runtimeLanguageContext.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ export class RuntimeLanguageContext {
108108
})
109109
this.supportedLanguageExtensionMap = createConstantMap<string, CodewhispererLanguage>({
110110
c: 'c',
111+
h: 'c',
111112
cpp: 'cpp',
113+
cc: 'cpp',
114+
'c++': 'cpp',
112115
cs: 'csharp',
113116
go: 'go',
114117
hcl: 'tf',

0 commit comments

Comments
 (0)