handle large unsigned constants
This commit is contained in:
parent
3d56bf3bcb
commit
90e49fe371
3 changed files with 19 additions and 9 deletions
|
@ -319,10 +319,10 @@ private:
|
|||
case schema::Value::INT16: return kj::strTree(value.getInt16());
|
||||
case schema::Value::INT32: return kj::strTree(value.getInt32());
|
||||
case schema::Value::INT64: return kj::strTree(value.getInt64(), "L");
|
||||
case schema::Value::UINT8: return kj::strTree(value.getUint8());
|
||||
case schema::Value::UINT16: return kj::strTree(value.getUint16());
|
||||
case schema::Value::UINT32: return kj::strTree(value.getUint32());
|
||||
case schema::Value::UINT64: return kj::strTree(value.getUint64(), "L");
|
||||
case schema::Value::UINT8: return kj::strTree(static_cast<int8_t>(value.getUint8()));
|
||||
case schema::Value::UINT16: return kj::strTree(static_cast<int16_t>(value.getUint16()));
|
||||
case schema::Value::UINT32: return kj::strTree(static_cast<int32_t>(value.getUint32()));
|
||||
case schema::Value::UINT64: return kj::strTree(static_cast<int64_t>(value.getUint64()), "L");
|
||||
case schema::Value::FLOAT32: return kj::strTree(value.getFloat32(), "f");
|
||||
case schema::Value::FLOAT64: return kj::strTree(value.getFloat64());
|
||||
case schema::Value::ENUM: {
|
||||
|
@ -1627,7 +1627,7 @@ private:
|
|||
auto constText = makeConstText(scope, name, schema.asConst());
|
||||
|
||||
return NodeTextNoSchema {
|
||||
kj::mv(constText.decl),
|
||||
kj::strTree(" ", kj::mv(constText.decl)),
|
||||
kj::strTree(),
|
||||
kj::strTree(),
|
||||
|
||||
|
|
|
@ -39,10 +39,18 @@ class EncodingSuite extends FunSuite {
|
|||
assert(-12345678 == TestConstants.INT32_CONST);
|
||||
assert(-123456789012345L == TestConstants.INT64_CONST);
|
||||
|
||||
assert(-22 == TestConstants.UINT8_CONST);
|
||||
assert(-19858 == TestConstants.UINT16_CONST);
|
||||
assert(-838178284 == TestConstants.UINT32_CONST);
|
||||
assert(-6101065172474983726L == TestConstants.UINT64_CONST);
|
||||
|
||||
assert(1234.5f == TestConstants.FLOAT32_CONST);
|
||||
assert(-123e45 == TestConstants.FLOAT64_CONST);
|
||||
}
|
||||
|
||||
test("GlobalConstants") {
|
||||
assert(12345 == GLOBAL_INT);
|
||||
}
|
||||
|
||||
// to debug, do this:
|
||||
//Serialize.writeMessage((new java.io.FileOutputStream("/Users/dwrensha/Desktop/test.dat")).getChannel(),
|
||||
|
|
|
@ -170,11 +170,13 @@ struct TestConstants {
|
|||
const int16Const :Int16 = -12345;
|
||||
const int32Const :Int32 = -12345678;
|
||||
const int64Const :Int64 = -123456789012345;
|
||||
# const uint8Const :UInt8 = 234;
|
||||
# const uint16Const :UInt16 = 45678;
|
||||
# const uint32Const :UInt32 = 3456789012;
|
||||
# const uint64Const :UInt64 = 12345678901234567890;
|
||||
const uint8Const :UInt8 = 234;
|
||||
const uint16Const :UInt16 = 45678;
|
||||
const uint32Const :UInt32 = 3456789012;
|
||||
const uint64Const :UInt64 = 12345678901234567890;
|
||||
const float32Const :Float32 = 1234.5;
|
||||
const float64Const :Float64 = -123e45;
|
||||
# ...
|
||||
}
|
||||
|
||||
const globalInt :UInt32 = 12345;
|
Loading…
Reference in a new issue