コード例 #1
0
ファイル: test_bounds.c プロジェクト: chiggs/nvc
END_TEST

START_TEST(test_case)
{
   const error_t expect[] = {
      {  13, "missing choice C in case statement" },
      {  19, "missing choice B in case statement" },
      {  30, "10 to 19" },
      {  36, "4 to 2147483647" },
      {  44, "2147483647" },
      {  51, "value 50 is already covered" },
      {  53, "range 60 to 64 is already covered" },
      {  59, "value -1 outside STD.STANDARD.NATURAL bounds" },
      {  58, "0 to 2147483647" },
      {  79, "choices cover only 2 of 8 possible values" },
      {  84, "expected 3 elements in aggregate but have 2" },
      {  86, "expected 3 elements in aggregate but have 4" },
      {  88, "expected 3 elements in string literal but have 2" },
      {  90, "expected 3 elements in string literal but have 4" },
      {  95, "choices do not cover all possible values" },
      { 101, "choices cover only 2 of 100 possible values" },
      { -1, NULL }
   };
   expect_errors(expect);

   input_from_file(TESTDIR "/bounds/case.vhd");

   tree_t a = parse_and_check(T_ENTITY, T_ARCH);
   fail_unless(sem_errors() == 0);

   simplify(a);
   bounds_check(a);

   fail_unless(bounds_errors() == (sizeof(expect) / sizeof(error_t)) - 1);
}
コード例 #2
0
ファイル: test_elab.c プロジェクト: manasdas17/nvc
END_TEST

START_TEST(test_copy1)
{
   input_from_file(TESTDIR "/elab/copy1.vhd");

   const error_t expect[] = {
      { -1, NULL }
   };
   expect_errors(expect);

   tree_t e = run_elab();

   int nfuncs = 0, nshared = 0;

   const int ndecls = tree_decls(e);
   for (int i = 0; i < ndecls; i++) {
      tree_t t = tree_decl(e, i);
      if (tree_kind(t) == T_FUNC_BODY)
         nfuncs++;
      else if (tree_kind(t) == T_VAR_DECL)
         nshared++;
   }

   fail_unless(nfuncs == 1);
   fail_unless(nshared == 2);
}
コード例 #3
0
ファイル: test_elab.c プロジェクト: manasdas17/nvc
END_TEST

START_TEST(test_open2)
{
   input_from_file(TESTDIR "/elab/open2.vhd");

   const error_t expect[] = {
      { -1, NULL }
   };
   expect_errors(expect);

   (void)run_elab();
}
コード例 #4
0
ファイル: test_elab.c プロジェクト: manasdas17/nvc
END_TEST

START_TEST(test_bounds10)
{
   input_from_file(TESTDIR "/elab/bounds10.vhd");

   const error_t expect[] = {
      { 10, "length of value 1 does not match length of target 101" },
      { -1, NULL }
   };
   expect_errors(expect);

   (void)run_elab();
}
コード例 #5
0
ファイル: test_elab.c プロジェクト: manasdas17/nvc
END_TEST

START_TEST(test_elab2)
{
   tree_t top;

   input_from_file(TESTDIR "/elab/elab2.vhd");

   const error_t expect[] = {
      { -1, NULL }
   };
   expect_errors(expect);

   top = run_elab();
}
コード例 #6
0
ファイル: test_elab.c プロジェクト: manasdas17/nvc
END_TEST

START_TEST(test_comp)
{
   input_from_file(TESTDIR "/elab/comp.vhd");

   const error_t expect[] = {
      { 55, "port Y not found in entity WORK.E2" },
      { 62, "type of port X in component declaration E3 is STD.STANDARD.BIT" },
      { -1, NULL }
   };
   expect_errors(expect);

   (void)run_elab();
}
コード例 #7
0
ファイル: test_elab.c プロジェクト: manasdas17/nvc
END_TEST

START_TEST(test_elab4)
{
   tree_t top;

   input_from_file(TESTDIR "/elab/elab4.vhd");

   const error_t expect[] = {
      { 21, "actual width 9 does not match formal X width 8" },
      { -1, NULL }
   };
   expect_errors(expect);

   top = run_elab();
}
コード例 #8
0
ファイル: test_elab.c プロジェクト: manasdas17/nvc
END_TEST

START_TEST(test_open)
{
   tree_t top;

   input_from_file(TESTDIR "/elab/open.vhd");

   const error_t expect[] = {
      { -1, NULL }
   };
   expect_errors(expect);

   top = run_elab();
   opt(top);

   // We used to delete all statements here but the behaviour
   // has changed
   fail_unless(tree_stmts(top) == 2);
}
コード例 #9
0
ファイル: test_bounds.c プロジェクト: chiggs/nvc
END_TEST

START_TEST(test_issue208)
{
   const error_t expect[] = {
      { 20, "case choices do not cover the following values of " },
      { -1, NULL }
   };
   expect_errors(expect);

   input_from_file(TESTDIR "/bounds/issue208.vhd");

   tree_t a = parse_and_check(T_ENTITY, T_ARCH);
   fail_unless(sem_errors() == 0);

   simplify(a);
   bounds_check(a);

   fail_unless(bounds_errors() == ARRAY_LEN(expect) - 1);
}
コード例 #10
0
ファイル: test_bounds.c プロジェクト: chiggs/nvc
END_TEST

START_TEST(test_issue150)
{
   const error_t expect[] = {
      { 10, "expected 8 elements in aggregate but have 6" },
      { -1, NULL }
   };
   expect_errors(expect);

   input_from_file(TESTDIR "/bounds/issue150.vhd");

   tree_t a = parse_and_check(T_ENTITY, T_ARCH);
   fail_unless(sem_errors() == 0);

   simplify(a);
   bounds_check(a);

   fail_unless(bounds_errors() == (sizeof(expect) / sizeof(error_t)) - 1);
}
コード例 #11
0
ファイル: test_bounds.c プロジェクト: chiggs/nvc
END_TEST

START_TEST(test_issue99)
{
   const error_t expect[] = {
      {  7, "type conversion argument -1.5 out of bounds 0 to 2147483647" },
      {  8, "type conversion argument -1 out of bounds 1 to 5" },
      { -1, NULL }
   };
   expect_errors(expect);

   input_from_file(TESTDIR "/bounds/issue99.vhd");

   tree_t a = parse_and_check(T_ENTITY, T_ARCH);
   fail_unless(sem_errors() == 0);

   simplify(a);
   bounds_check(a);

   fail_unless(bounds_errors() == (sizeof(expect) / sizeof(error_t)) - 1);
}
コード例 #12
0
ファイル: test_bounds.c プロジェクト: chiggs/nvc
END_TEST

START_TEST(test_issue54)
{
   const error_t expect[] = {
      { 12, "aggregate index 3 out of bounds 7 downto 4" },
      { 12, "aggregate index 0 out of bounds 7 downto 4" },
      { -1, NULL }
   };
   expect_errors(expect);

   input_from_file(TESTDIR "/bounds/issue54.vhd");

   tree_t a = parse_and_check(T_ENTITY, T_ARCH);
   fail_unless(sem_errors() == 0);

   simplify(a);
   bounds_check(a);

   fail_unless(bounds_errors() == (sizeof(expect) / sizeof(error_t)) - 1);
}
コード例 #13
0
ファイル: test_elab.c プロジェクト: manasdas17/nvc
END_TEST

START_TEST(test_issue19)
{
   input_from_file(TESTDIR "/elab/issue19.vhd");

   const error_t expect[] = {
      { -1, NULL }
   };
   expect_errors(expect);

   tree_t e = run_elab();

   tree_t tmp = NULL;
   const int ndecls = tree_decls(e);
   for (int i = 0; (i < ndecls) && (tmp == NULL); i++) {
      tree_t t = tree_decl(e, i);
      if (icmp(tree_ident(t), ":comp6:c1:tmp"))
         tmp = t;
   }

   fail_if(tmp == NULL);

   tree_t value = tree_value(tmp);
   fail_unless(tree_kind(value) == T_LITERAL);
   fail_unless(tree_ival(value) == 32);

   for (int i = 0; (i < ndecls) && (tmp == NULL); i++) {
      tree_t t = tree_decl(e, i);
      if (icmp(tree_ident(t), ":comp6:c1:tmp3"))
         tmp = t;
   }

   fail_if(tmp == NULL);

   value = tree_value(tmp);
   fail_unless(tree_kind(value) == T_LITERAL);
   fail_unless(tree_ival(value) == 32);
}