/* * Copyright (c) 2004-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ use namespace Facebook\XHP\Core as x; use type Facebook\XHP\HTML\div; use function Facebook\FBExpect\expect; enum TestEnum: int { HERP = 1; DERP = 2; } final xhp class test:hack_enum_attribute extends x\element { attribute TestEnum foo @required; <<__Override>> protected async function renderAsync(): Awaitable { $foo = TestEnum::getNames()[$this->:foo]; return
{$foo}
; } } final class HackEnumAttributesTest extends Facebook\HackTest\HackTest { public async function testValidValues(): Awaitable { $x = ; expect(await $x->toStringAsync())->toEqual('
HERP
'); $x = ; expect(await $x->toStringAsync())->toEqual('
DERP
'); } public async function testValidRawValues(): Awaitable { // UNSAFE $x = ; expect(await $x->toStringAsync())->toEqual('
HERP
'); $x = ; expect(await $x->toStringAsync())->toEqual('
DERP
'); } }