• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2021-2024 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'use strict';
16
17let etsVm = gtest.etsVm;
18exports.etsVm = etsVm;
19
20exports.nop = function () {};
21exports.identity = function (v) {
22	return v;
23};
24exports.stringifyValue = function (v) {
25	return typeof v + ':' + v;
26};
27exports.stringifyArgs = function (...args) {
28	return args.toString();
29};
30exports.setProtoConstructor = function (v) {
31	return Object.getPrototypeOf(v).constructor;
32};
33exports.applyArgs = function (fn, ...args) {
34	return fn(...args);
35};
36exports.throwValue = function (v) {
37	throw v;
38};
39exports.log = function (...args) {
40	console.log(...args);
41};
42exports.getProp = function (v, p) {
43	return v[p];
44};
45
46exports.sum = function (a, b) {
47	return a + b;
48};
49exports.makeCar = function (v) {
50	this.color = v;
51};
52
53exports.makeTestProxy = function () {
54	Object.defineProperty(this, 'foo', {
55		get: function () {
56			throw Error('get exception');
57		},
58		set: function () {
59			throw Error('set exception');
60		},
61	});
62};
63