ValueType: Test promotions

This commit is contained in:
Daniel Marjamäki 2015-10-07 19:50:33 +02:00
parent 0fa3b8806c
commit 2fd27ff729
1 changed files with 12 additions and 0 deletions

View File

@ -2971,6 +2971,18 @@ private:
ASSERT_EQUALS("float", typeOf("1.2f + 3", "+")); ASSERT_EQUALS("float", typeOf("1.2f + 3", "+"));
ASSERT_EQUALS("float", typeOf("1 + 2.3f", "+")); ASSERT_EQUALS("float", typeOf("1 + 2.3f", "+"));
// promotions
ASSERT_EQUALS("signed int", typeOf("(char)1 + (char)2", "+"));
ASSERT_EQUALS("signed int", typeOf("(short)1 + (short)2", "+"));
ASSERT_EQUALS("signed int", typeOf("(signed int)1 + (signed char)2", "+"));
ASSERT_EQUALS("signed int", typeOf("(signed int)1 + (unsigned char)2", "+"));
ASSERT_EQUALS("unsigned int", typeOf("(unsigned int)1 + (signed char)2", "+"));
ASSERT_EQUALS("unsigned int", typeOf("(unsigned int)1 + (unsigned char)2", "+"));
ASSERT_EQUALS("unsigned int", typeOf("(unsigned int)1 + (signed int)2", "+"));
ASSERT_EQUALS("unsigned int", typeOf("(unsigned int)1 + (unsigned int)2", "+"));
ASSERT_EQUALS("signed long", typeOf("(signed long)1 + (unsigned int)2", "+"));
ASSERT_EQUALS("unsigned long", typeOf("(unsigned long)1 + (signed int)2", "+"));
// char * // char *
ASSERT_EQUALS("const char *", typeOf("\"hello\" + 1", "+")); ASSERT_EQUALS("const char *", typeOf("\"hello\" + 1", "+"));
ASSERT_EQUALS("char", typeOf("\"hello\"[1]", "[")); ASSERT_EQUALS("char", typeOf("\"hello\"[1]", "["));