2018-06-19 23:16:01 +02:00
|
|
|
// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#include "../../lib/evaluate/expression.h"
|
2018-06-19 23:17:14 +02:00
|
|
|
#include "testing.h"
|
2018-06-19 23:16:01 +02:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
2018-06-21 01:50:27 +02:00
|
|
|
#include <sstream>
|
|
|
|
#include <iostream> // TODO pmk rm
|
2018-06-19 23:16:01 +02:00
|
|
|
|
|
|
|
using namespace Fortran::evaluate;
|
|
|
|
|
|
|
|
int main() {
|
2018-06-22 00:35:25 +02:00
|
|
|
TEST(DefaultIntegerExpr::Result::Dump() == "Integer(4)");
|
|
|
|
DefaultIntegerExpr ie{666};
|
2018-06-21 01:50:27 +02:00
|
|
|
std::stringstream ss;
|
|
|
|
ie.Dump(ss);
|
|
|
|
TEST(ss.str() == "666");
|
2018-06-22 00:35:25 +02:00
|
|
|
DefaultIntegerExpr one{DefaultIntegerExpr::Constant{1}};
|
2018-06-22 21:22:50 +02:00
|
|
|
auto minusOne{-DefaultIntegerExpr{1}};
|
|
|
|
DefaultIntegerExpr incr{DefaultIntegerExpr::Add{ie, minusOne}};
|
2018-06-21 01:50:27 +02:00
|
|
|
incr.Dump(std::cout) << '\n';
|
2018-06-22 21:22:50 +02:00
|
|
|
incr = ie + one;
|
|
|
|
incr.Dump(std::cout) << '\n';
|
|
|
|
auto three{std::move(one) + DefaultIntegerExpr{2}};
|
|
|
|
three.Dump(std::cout) << '\n';
|
|
|
|
LogicalExpr cmp{std::move(incr) <= DefaultIntegerExpr{2}};
|
2018-06-22 20:02:54 +02:00
|
|
|
cmp.Dump(std::cout) << '\n';
|
2018-06-19 23:16:01 +02:00
|
|
|
return testing::Complete();
|
|
|
|
}
|