diff options
| author | 2015-06-10 15:55:30 -0700 | |
|---|---|---|
| committer | 2015-06-18 10:22:27 -0700 | |
| commit | 158f35c98e2ec0d40d2c032b8cdce5fb60944a7f (patch) | |
| tree | 63bb3bbed85b0add42c7fdc714cd611424d8af2e /cmdline/cmdline_parser_test.cc | |
| parent | c449e8b79aaaf156ce055524c41474cc1200ed5a (diff) | |
interpreter: Add experimental lambda opcodes for invoke/create-lambda
These opcodes are not yet fully specified, and *will* change before they become shippable.
Do not write production code against experimental opcodes.
--
Implement partial interpreter support for new dex instructions invoke/create-lambda, and a
new opcode format 25x.
* Does not verify, in fact verification will soft fail when we see those opcodes.
* Compilers will punt to interpreter since they don't support new opcodes.
* As there is no way to capture/liberate variables yet, the "closure" is just
an ArtMethod for the time being.
All new opcodes are disabled by default, use runtime option -Xexperimental-lambdas to enable them.
For example:
dalvikvm ... -Xexperimental-lambdas ...
dex2oat --runtime-arg -Xexperimental-lambdas ...
Change-Id: I6c996ca32a9b54ec45ec21d7a959b84dfb8a24eb
Diffstat (limited to 'cmdline/cmdline_parser_test.cc')
| -rw-r--r-- | cmdline/cmdline_parser_test.cc | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/cmdline/cmdline_parser_test.cc b/cmdline/cmdline_parser_test.cc index 6192be75a4..98fd327f02 100644 --- a/cmdline/cmdline_parser_test.cc +++ b/cmdline/cmdline_parser_test.cc @@ -101,6 +101,19 @@ namespace art { return ::testing::AssertionFailure() << "key was not in the map"; } + template <typename TMap, typename TKey, typename T> + ::testing::AssertionResult IsExpectedDefaultKeyValue(const T& expected, + const TMap& map, + const TKey& key) { + const T& actual = map.GetOrDefault(key); + if (!UsuallyEquals(expected, actual)) { + return ::testing::AssertionFailure() + << "expected " << detail::ToStringAny(expected) << " but got " + << detail::ToStringAny(actual); + } + return ::testing::AssertionSuccess(); + } + class CmdlineParserTest : public ::testing::Test { public: CmdlineParserTest() = default; @@ -145,13 +158,23 @@ class CmdlineParserTest : public ::testing::Test { #define EXPECT_KEY_EXISTS(map, key) EXPECT_TRUE((map).Exists(key)) #define EXPECT_KEY_VALUE(map, key, expected) EXPECT_TRUE(IsExpectedKeyValue(expected, map, key)) +#define EXPECT_DEFAULT_KEY_VALUE(map, key, expected) EXPECT_TRUE(IsExpectedDefaultKeyValue(expected, map, key)) -#define EXPECT_SINGLE_PARSE_EMPTY_SUCCESS(argv) \ +#define _EXPECT_SINGLE_PARSE_EMPTY_SUCCESS(argv) \ do { \ EXPECT_TRUE(IsResultSuccessful(parser_->Parse(argv))); \ EXPECT_EQ(0u, parser_->GetArgumentsMap().Size()); \ + +#define EXPECT_SINGLE_PARSE_EMPTY_SUCCESS(argv) \ + _EXPECT_SINGLE_PARSE_EMPTY_SUCCESS(argv); \ } while (false) +#define EXPECT_SINGLE_PARSE_DEFAULT_VALUE(expected, argv, key)\ + _EXPECT_SINGLE_PARSE_EMPTY_SUCCESS(argv); \ + RuntimeArgumentMap args = parser_->ReleaseArgumentsMap(); \ + EXPECT_DEFAULT_KEY_VALUE(args, key, expected); \ + } while (false) // NOLINT [readability/namespace] [5] + #define _EXPECT_SINGLE_PARSE_EXISTS(argv, key) \ do { \ EXPECT_TRUE(IsResultSuccessful(parser_->Parse(argv))); \ @@ -509,6 +532,24 @@ TEST_F(CmdlineParserTest, TestProfilerOptions) { } } // TEST_F +/* -X[no]experimental-lambdas */ +TEST_F(CmdlineParserTest, TestExperimentalLambdas) { + // Off by default + EXPECT_SINGLE_PARSE_DEFAULT_VALUE(false, + "", + M::ExperimentalLambdas); + + // Disabled explicitly + EXPECT_SINGLE_PARSE_VALUE(false, + "-Xnoexperimental-lambdas", + M::ExperimentalLambdas); + + // Enabled explicitly + EXPECT_SINGLE_PARSE_VALUE(true, + "-Xexperimental-lambdas", + M::ExperimentalLambdas); +} + TEST_F(CmdlineParserTest, TestIgnoreUnrecognized) { RuntimeParser::Builder parserBuilder; |