Reflecting primitive types such as “double” results in unexpected output

后端 未结 2 1992
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-22 10:36

The following example fails with:

FAIL: MyClass tests getClassReturnsConstructorForDouble
  Expected: ?:
    Actual: ?:
2条回答
  •  遥遥无期
    2021-01-22 11:15

    I think reflection is returning the correct types to you, but your test fails because objectClass and object.runtimeType are two seperate objects and therefore not equal to each other. If you convert them to string first they will equal each other:

    expect(objectClass.toString(), equals(object.runtimeType.toString()));
    

提交回复
热议问题