• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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 assert = require('assert');
17
18enum Color {
19  RED = 1,
20  GREEN = 2,
21  BLUE = 4
22}
23
24namespace Color {
25  export function mixColor(colorName: string): any {
26    if (colorName === "yellow") {
27      return Color.RED + Color.GREEN;
28    } else if (colorName === "white") {
29      return Color.RED + Color.GREEN + Color.BLUE;
30    } else if (colorName === "magenta") {
31      return Color.RED + Color.BLUE;
32    } else if (colorName === "cyan") {
33      return Color.GREEN + Color.BLUE;
34    }
35  }
36}
37
38assert(Color.mixColor('yellow') === 3, 'success');
39
40assert(Color.mixColor('white') === 7, 'success');
41
42assert(Color.mixColor('magenta') === 5, 'success');
43
44assert(Color.mixColor('cyan') === 6, 'success');
45