Skip to content

Commit

Permalink
APL-CORE: August 2021 Release of APL 1.7 compilant core engine (1.7.1)
Browse files Browse the repository at this point in the history
For more details on this release refer to CHANGELOG.md

To learn about APL see: https://developer.amazon.com/docs/alexa-presentation-language/understand-apl.html
  • Loading branch information
durjo-amz committed Aug 17, 2021
1 parent 82cce6f commit 3fee5eb
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [1.7.1]

### Changed

- Bug fixes

## [1.7.0]

This release adds support for version 1.7 of the APL specification.
Expand Down
2 changes: 1 addition & 1 deletion aplcore/src/primitives/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ Object::serialize(rapidjson::Document::AllocatorType& allocator) const
case kBoolType:
return rapidjson::Value(static_cast<bool>(mU.value));
case kNumberType:
return rapidjson::Value(mU.value);
return std::isfinite(mU.value) ? rapidjson::Value(mU.value) : rapidjson::Value();
case kStringType:
return rapidjson::Value(mU.string.c_str(), allocator);
case kArrayType: {
Expand Down
45 changes: 43 additions & 2 deletions unit/primitives/unittest_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ TEST(ObjectTest, WhenDimensionIsNotFiniteSerializeReturnsZero)

class DocumentObjectTest : public CommandTest {};

static const char * SEND_EVENT_NEW_NAN = R"apl({
static const char * SEND_EVENT_DIMENSION_NAN = R"apl({
"type": "APL",
"version": "1.1",
"resources": [
Expand All @@ -683,14 +683,55 @@ static const char * SEND_EVENT_NEW_NAN = R"apl({

TEST_F(DocumentObjectTest, WithNewArguments)
{
loadDocument(SEND_EVENT_NEW_NAN);
loadDocument(SEND_EVENT_DIMENSION_NAN);

auto expectedObject = Object(0);

performClick(1, 1);
ASSERT_TRUE(root->hasEvent());
auto event = root->popEvent();

ASSERT_EQ(kEventTypeSendEvent, event.getType());
auto args = event.getValue(kEventPropertyArguments);
ASSERT_TRUE(args.isArray());
ASSERT_EQ(args.size(), 1);
ASSERT_TRUE(IsEqual(expectedObject, args.at(0)));
}


static const char * SEND_EVENT_NUMBER_NAN = R"apl({
"type": "APL",
"version": "1.1",
"resources": [
{
"number": {
"value": "${100/0}"
}
}
],
"mainTemplate": {
"item": {
"type": "TouchWrapper",
"onPress": {
"type": "SendEvent",
"arguments": [
"@value"
]
}
}
}
})apl";

TEST_F(DocumentObjectTest, WhenNumberIsNotFiniteSerializeReturnsNull)
{
loadDocument(SEND_EVENT_NUMBER_NAN);

auto expectedObject = Object();

performClick(1, 1);
ASSERT_TRUE(root->hasEvent());
auto event = root->popEvent();

ASSERT_EQ(kEventTypeSendEvent, event.getType());
auto args = event.getValue(kEventPropertyArguments);
ASSERT_TRUE(args.isArray());
Expand Down

0 comments on commit 3fee5eb

Please sign in to comment.