1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { expect } from 'chai'; 17import * as ts from "typescript"; 18import { compileStringLiteral } from "../../src/expression/stringLiteral"; 19import { 20 LdaStr 21} from "../../src/irnodes"; 22import { PandaGen } from "../../src/pandagen"; 23import { checkInstructions } from "../utils/base"; 24import { creatAstFromSnippet } from "../utils/asthelper"; 25 26describe("compileStringLiteral", function () { 27 it("i am a string", function () { 28 let pandaGen = new PandaGen("ignored", creatAstFromSnippet("i am a string"), 0, undefined); 29 let node: ts.StringLiteral = ts.createStringLiteral("i am a string"); 30 compileStringLiteral(pandaGen, node); 31 let insns = pandaGen.getInsns(); 32 let expected = [new LdaStr("i am a string")]; 33 expect(checkInstructions(insns, expected)).to.be.true; 34 }); 35})