<commit_before><?php namespace net\xp_framework\unittest\reflection;

use lang\Type;
use lang\Enum;
use lang\Primitive;
use lang\ArrayType;
use lang\MapType;
use lang\TypeUnion;
use lang\XPClass;
use lang\ElementNotFoundException;
use lang\DynamicClassLoader;
use lang\IllegalArgumentException;
use unittest\actions\VerifyThat;

/**
 * TestCase for HACK language feature support
 *
 * @see  xp://lang.Type
 */
#[@action(new VerifyThat(function() { return defined('HHVM_VERSION'); }))]
class HackLanguageSupportTest extends \unittest\TestCase {

  /**
   * Returns a fixture for integration tests
   *
   * @return lang.XPClass
   */
  private function testClass() {
    return XPClass::forName('net.xp_framework.unittest.reflection.HackLanguageSupport');
  }

  /**
   * Returns a fixture for integration tests
   *
   * @return lang.XPClass
   */
  private function enumClass() {
    return XPClass::forName('net.xp_framework.unittest.reflection.HackLanguageEnum');
  }

  #[@test]
  public function mixed_type() {
    $this->assertEquals(Type::$VAR, Type::forName('HH\mixed'));
  }

  #[@test]
  public function string_type() {
    $this->assertEquals(Primitive::$STRING, Type::forName('HH\string'));
  }

  #[@test]
  public function int_type() {
    $this->assertEquals(Primitive::$INT, Type::forName('HH\int'));
  }

  #[@test]
  public function double_type() {
    $this->assertEquals(Primitive::$DOUBLE, Type::forName('HH\float'));
  }

  #[@test]
  public function bool_type() {
    $this->assertEquals(Primitive::$BOOL, Type::forName('HH\bool'));
  }

  #[@test]
  public function array_of_string_type() {
    $this->assertEquals(new ArrayType('string'), Type::forName('array<HH\string>'));
  }

  #[@test]
  public function map_of_int_type() {
    $this->assertEquals(new MapType('int'), Type::forName('array<HH\string, HH\int>'));
  }

  #[@test]
  public function nullable_type() {
    $this->assertEquals(XPClass::forName('lang.Object'), Type::forName('?lang\Object'));
  }

  #[@test]
  public function method_string_return_type() {
    $this->assertEquals(Primitive::$STRING, $this->testClass()->getMethod('returnsString')->getReturnType());
  }

  #[@test]
  public function method_string_return_type_name() {
    $this->assertEquals('string', $this->testClass()->getMethod('returnsString')->getReturnTypeName());
  }

  #[@test]
  public function method_void_return_type() {
    $this->assertEquals(Type::$VOID, $this->testClass()->getMethod('returnsNothing')->getReturnType());
  }

  #[@test]
  public function method_noreturn_type() {
    $this->assertEquals(Type::$VOID, $this->testClass()->getMethod('returnsNoreturn')->getReturnType());
  }

  #[@test]
  public function method_this_return_type() {
    $this->assertEquals($this->testClass(), $this->testClass()->getMethod('returnsThis')->getReturnType());
  }
<commit_msg>Only check for "noreturn" return type in HHVM >= 3.7.0<commit_after><?php namespace net\xp_framework\unittest\reflection;

use lang\Type;
use lang\Enum;
use lang\Primitive;
use lang\ArrayType;
use lang\MapType;
use lang\TypeUnion;
use lang\XPClass;
use lang\ElementNotFoundException;
use lang\DynamicClassLoader;
use lang\IllegalArgumentException;
use unittest\actions\VerifyThat;

/**
 * TestCase for HACK language feature support
 *
 * @see  xp://lang.Type
 */
#[@action(new VerifyThat(function() { return defined('HHVM_VERSION'); }))]
class HackLanguageSupportTest extends \unittest\TestCase {

  /**
   * Returns a fixture for integration tests
   *
   * @return lang.XPClass
   */
  private function testClass() {
    return XPClass::forName('net.xp_framework.unittest.reflection.HackLanguageSupport');
  }

  /**
   * Returns a fixture for integration tests
   *
   * @return lang.XPClass
   */
  private function enumClass() {
    return XPClass::forName('net.xp_framework.unittest.reflection.HackLanguageEnum');
  }

  #[@test]
  public function mixed_type() {
    $this->assertEquals(Type::$VAR, Type::forName('HH\mixed'));
  }

  #[@test]
  public function string_type() {
    $this->assertEquals(Primitive::$STRING, Type::forName('HH\string'));
  }

  #[@test]
  public function int_type() {
    $this->assertEquals(Primitive::$INT, Type::forName('HH\int'));
  }

  #[@test]
  public function double_type() {
    $this->assertEquals(Primitive::$DOUBLE, Type::forName('HH\float'));
  }

  #[@test]
  public function bool_type() {
    $this->assertEquals(Primitive::$BOOL, Type::forName('HH\bool'));
  }

  #[@test]
  public function array_of_string_type() {
    $this->assertEquals(new ArrayType('string'), Type::forName('array<HH\string>'));
  }

  #[@test]
  public function map_of_int_type() {
    $this->assertEquals(new MapType('int'), Type::forName('array<HH\string, HH\int>'));
  }

  #[@test]
  public function nullable_type() {
    $this->assertEquals(XPClass::forName('lang.Object'), Type::forName('?lang\Object'));
  }

  #[@test]
  public function method_string_return_type() {
    $this->assertEquals(Primitive::$STRING, $this->testClass()->getMethod('returnsString')->getReturnType());
  }

  #[@test]
  public function method_string_return_type_name() {
    $this->assertEquals('string', $this->testClass()->getMethod('returnsString')->getReturnTypeName());
  }

  #[@test]
  public function method_void_return_type() {
    $this->assertEquals(Type::$VOID, $this->testClass()->getMethod('returnsNothing')->getReturnType());
  }

  #[@test, @action(new VerifyThat(function() { return version_compare(HHVM_VERSION, '3.7.0', 'ge'); }))]
  public function method_noreturn_type() {
    $this->assertEquals(Type::$VOID, $this->testClass()->getMethod('returnsNoreturn')->getReturnType());
  }

  #[@test]
  public function method_this_return_type() {
    $this->assertEquals($this->testClass(), $this->testClass()->getMethod('returnsThis')->getReturnType());
  }

{'fraction_non_alphanumeric': 0.17418911961558264, 'fraction_numerical': 0.0010296893770379268, 'mean_word_length': 5.096234309623431, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 66, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6651400', 'n_tokens_mistral': 1866, 'n_tokens_neox': 1848, 'n_words': 310}