Fix the license header
This commit is contained in:
parent
7dc587ecbc
commit
f663ba0c25
|
@ -82,7 +82,7 @@ Check out the =builder= script for more subcommands and details.
|
|||
- [[https://github.com/muqsitnawaz/modern-cpp-cheatsheet][Modern C++ Cheatsheet]]
|
||||
|
||||
* License
|
||||
Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
|
||||
*Serene* is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
2
builder
2
builder
|
@ -1,7 +1,7 @@
|
|||
#! /bin/bash
|
||||
# Serene Programming Language
|
||||
#
|
||||
# Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
# Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Serene Programming Language
|
||||
#
|
||||
# Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
# Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; serene-dev --- Serene's development lib for Emacs users -*- lexical-binding: t; -*-
|
||||
;;
|
||||
;; Copyright (c) 2019-2021 Sameer Rahmani
|
||||
;; Copyright (c) 2019-2022 Sameer Rahmani
|
||||
;;
|
||||
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
||||
;; URL: https://serene-lang.org
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- C++ -*-
|
||||
* Serene programming language.
|
||||
*
|
||||
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
* Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -22,20 +22,22 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "./test_helpers.cpp.inc"
|
||||
#include "serene/context.h"
|
||||
#include "serene/namespace.h"
|
||||
|
||||
#include "./test_helpers.cpp.inc"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
namespace serene {
|
||||
|
||||
TEST_CASE("Context tests", "[context]") {
|
||||
auto ctx = makeSereneContext();
|
||||
auto ns = ctx->getNS("blah");
|
||||
auto ns = ctx->getNS("blah");
|
||||
|
||||
REQUIRE_FALSE(ns);
|
||||
|
||||
auto userNs = makeNamespace(*ctx, "user", llvm::Optional<llvm::StringRef>("/some/file"));
|
||||
auto userNs = makeNamespace(*ctx, "user",
|
||||
llvm::Optional<llvm::StringRef>("/some/file"));
|
||||
|
||||
CHECK(userNs->name == "user");
|
||||
REQUIRE(userNs->filename);
|
||||
|
@ -46,9 +48,9 @@ TEST_CASE("Context tests", "[context]") {
|
|||
REQUIRE(ns);
|
||||
CHECK(ns->name == userNs->name);
|
||||
|
||||
|
||||
/// Creating new ns with the same name overrides the old one
|
||||
auto userNs1 = makeNamespace(*ctx, "user", llvm::Optional<llvm::StringRef>("/some/other/file"));
|
||||
auto userNs1 = makeNamespace(
|
||||
*ctx, "user", llvm::Optional<llvm::StringRef>("/some/other/file"));
|
||||
|
||||
ns = ctx->getNS("user");
|
||||
|
||||
|
@ -56,12 +58,12 @@ TEST_CASE("Context tests", "[context]") {
|
|||
CHECK(ns->name == userNs1->name);
|
||||
REQUIRE(ns->filename);
|
||||
CHECK(ns->filename.getValue() == "/some/other/file");
|
||||
|
||||
};
|
||||
|
||||
TEST_CASE("Get and Set current namespace", "[context]") {
|
||||
auto ctx = makeSereneContext();
|
||||
auto userNs = makeNamespace(*ctx, "user", llvm::Optional<llvm::StringRef>("/some/file"));
|
||||
auto ctx = makeSereneContext();
|
||||
auto userNs = makeNamespace(*ctx, "user",
|
||||
llvm::Optional<llvm::StringRef>("/some/file"));
|
||||
|
||||
auto isSet = ctx->setCurrentNS("user");
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- C++ -*-
|
||||
* Serene programming language.
|
||||
*
|
||||
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
* Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -22,20 +22,22 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "./test_helpers.cpp.inc"
|
||||
#include "serene/environment.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
#include "serene/exprs/symbol.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
||||
#include "./test_helpers.cpp.inc"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
namespace serene {
|
||||
#include <llvm/ADT/StringRef.h>
|
||||
|
||||
namespace serene {
|
||||
|
||||
TEST_CASE("Environment tests", "[environment]") {
|
||||
std::unique_ptr<reader::LocationRange> range(dummyLocation());
|
||||
|
||||
exprs::Node sym = exprs::make<exprs::Symbol>(*range.get(), llvm::StringRef("example"));
|
||||
exprs::Node sym =
|
||||
exprs::make<exprs::Symbol>(*range.get(), llvm::StringRef("example"));
|
||||
|
||||
Environment<llvm::StringRef, exprs::Node> e;
|
||||
llvm::Optional<exprs::Node> result = e.lookup("a");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- C++ -*-
|
||||
* Serene programming language.
|
||||
*
|
||||
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
* Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -22,25 +22,25 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "../test_helpers.cpp.inc"
|
||||
#include "serene/exprs/symbol.h"
|
||||
#include "serene/errors.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "serene/exprs/symbol.h"
|
||||
|
||||
#include "../test_helpers.cpp.inc"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
|
||||
#include <llvm/Support/Casting.h>
|
||||
|
||||
namespace serene {
|
||||
namespace errors {
|
||||
|
||||
|
||||
TEST_CASE("Error Expression", "[expression]") {
|
||||
std::unique_ptr<reader::LocationRange> range(dummyLocation());
|
||||
auto err = exprs::makeAndCast<Error>(*range.get(), &DefExpectSymbol, "Something Failed");
|
||||
auto err = exprs::makeAndCast<Error>(*range.get(), &DefExpectSymbol,
|
||||
"Something Failed");
|
||||
|
||||
CHECK(err->getVariant()->id == E0001);
|
||||
CHECK(err->toString() == "<Error E1: Something Failed>");
|
||||
};
|
||||
|
||||
} // namespace exprs
|
||||
} // namespace errors
|
||||
} // namespace serene
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- C++ -*-
|
||||
* Serene programming language.
|
||||
*
|
||||
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
* Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -22,11 +22,13 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "../test_helpers.cpp.inc"
|
||||
#include "serene/exprs/expression.h"
|
||||
#include "serene/exprs/list.h"
|
||||
#include "serene/exprs/symbol.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
|
||||
#include "../test_helpers.cpp.inc"
|
||||
|
||||
#include <llvm/ADT/ArrayRef.h>
|
||||
|
||||
namespace serene {
|
||||
namespace exprs {
|
||||
|
@ -36,7 +38,7 @@ TEST_CASE("Public Expression API", "[expression]") {
|
|||
auto sym = make<Symbol>(*range.get(), "example");
|
||||
|
||||
REQUIRE(sym->getType() == ExprType::Symbol);
|
||||
CHECK(sym->toString() == "<Symbol example>");
|
||||
CHECK(sym->toString() == "<Symbol example>");
|
||||
|
||||
auto list = makeAndCast<List>(*range.get(), sym);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- C++ -*-
|
||||
* Serene programming language.
|
||||
*
|
||||
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
* Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -22,13 +22,14 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "../test_helpers.cpp.inc"
|
||||
#include "serene/exprs/expression.h"
|
||||
#include "serene/exprs/list.h"
|
||||
#include "serene/exprs/symbol.h"
|
||||
#include "serene/namespace.h"
|
||||
#include "serene/reader/reader.h"
|
||||
#include "serene/reader/semantics.h"
|
||||
|
||||
#include "../test_helpers.cpp.inc"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
namespace serene {
|
||||
|
@ -37,7 +38,7 @@ namespace exprs {
|
|||
TEST_CASE("List Expression", "[expression]") {
|
||||
std::unique_ptr<reader::LocationRange> range(dummyLocation());
|
||||
|
||||
Node sym = make<Symbol>(*range.get(), llvm::StringRef("example"));
|
||||
Node sym = make<Symbol>(*range.get(), llvm::StringRef("example"));
|
||||
Node sym1 = make<Symbol>(*range.get(), llvm::StringRef("example1"));
|
||||
|
||||
Node list = make<List>(*range.get());
|
||||
|
@ -81,30 +82,30 @@ TEST_CASE("List Expression", "[expression]") {
|
|||
};
|
||||
|
||||
TEST_CASE("List semantic analysis of 'def'", "[semantic]") {
|
||||
auto ctx = makeSereneContext();
|
||||
auto ns = makeNamespace(*ctx, "user", llvm::None);
|
||||
auto ast = reader::read("(def (a) b)");
|
||||
auto ctx = makeSereneContext();
|
||||
auto ns = makeNamespace(*ctx, "user", llvm::None);
|
||||
auto ast = reader::read("(def (a) b)");
|
||||
auto afterAst = reader::analyze(*ctx, ast.getValue());
|
||||
REQUIRE_FALSE(afterAst);
|
||||
// Fetch the first error
|
||||
CHECK(afterAst.getError()[0]->toString() == "<Error E1: >");
|
||||
|
||||
ast = reader::read("(def a)");
|
||||
ast = reader::read("(def a)");
|
||||
afterAst = reader::analyze(*ctx, ast.getValue());
|
||||
REQUIRE_FALSE(afterAst);
|
||||
CHECK(afterAst.getError()[0]->toString() == "<Error E2: Expected 3 got 2>");
|
||||
|
||||
ast = reader::read("(def a b c)");
|
||||
ast = reader::read("(def a b c)");
|
||||
afterAst = reader::analyze(*ctx, ast.getValue());
|
||||
REQUIRE_FALSE(afterAst);
|
||||
CHECK(afterAst.getError()[0]->toString() == "<Error E2: Expected 3 got 4>");
|
||||
|
||||
ast = reader::read("(def a b)");
|
||||
ast = reader::read("(def a b)");
|
||||
afterAst = reader::analyze(*ctx, ast.getValue());
|
||||
REQUIRE(afterAst);
|
||||
CHECK(astToString(&afterAst.getValue()) == "<Def a -> <Symbol b>>");
|
||||
|
||||
ast = reader::read("(def a (fn () a))");
|
||||
ast = reader::read("(def a (fn () a))");
|
||||
afterAst = reader::analyze(*ctx, ast.getValue());
|
||||
REQUIRE(afterAst);
|
||||
CHECK(astToString(&afterAst.getValue()) ==
|
||||
|
@ -112,73 +113,77 @@ TEST_CASE("List semantic analysis of 'def'", "[semantic]") {
|
|||
}
|
||||
|
||||
TEST_CASE("List semantic analysis for 'fn'", "[semantic]") {
|
||||
auto ctx = makeSereneContext();
|
||||
auto ns = makeNamespace(*ctx, "user", llvm::None);
|
||||
auto ast = reader::read("(fn)");
|
||||
auto ctx = makeSereneContext();
|
||||
auto ns = makeNamespace(*ctx, "user", llvm::None);
|
||||
auto ast = reader::read("(fn)");
|
||||
auto afterAst = reader::analyze(*ctx, ast.getValue());
|
||||
REQUIRE_FALSE(afterAst);
|
||||
REQUIRE(afterAst.getError().size() == 1);
|
||||
CHECK(afterAst.getError()[0]->toString() ==
|
||||
"<Error E3: The argument list is mandatory.>");
|
||||
|
||||
ast = reader::read("(fn ())");
|
||||
ast = reader::read("(fn ())");
|
||||
afterAst = reader::analyze(*ctx, ast.getValue());
|
||||
REQUIRE(afterAst);
|
||||
CHECK(astToString(&afterAst.getValue()) == "<Fn ___fn___0 <List -> to <>>");
|
||||
|
||||
ast = reader::read("(fn (a b c) a a a)");
|
||||
ast = reader::read("(fn (a b c) a a a)");
|
||||
afterAst = reader::analyze(*ctx, ast.getValue());
|
||||
REQUIRE(afterAst);
|
||||
CHECK(astToString(&afterAst.getValue()) ==
|
||||
"<Fn ___fn___1 <List <Symbol a> <Symbol b> <Symbol c>> to <Symbol a> <Symbol a> <Symbol a>>"
|
||||
);
|
||||
"<Fn ___fn___1 <List <Symbol a> <Symbol b> <Symbol c>> to <Symbol a> "
|
||||
"<Symbol a> <Symbol a>>");
|
||||
|
||||
ast = reader::read("(fn () a b)");
|
||||
ast = reader::read("(fn () a b)");
|
||||
afterAst = reader::analyze(*ctx, ast.getValue());
|
||||
REQUIRE(afterAst);
|
||||
CHECK(astToString(&afterAst.getValue()) ==
|
||||
"<Fn ___fn___2 <List -> to <Symbol a> <Symbol b>>");
|
||||
|
||||
ast = reader::read("(fn (x) (fn (y) x) z)");
|
||||
ast = reader::read("(fn (x) (fn (y) x) z)");
|
||||
afterAst = reader::analyze(*ctx, ast.getValue());
|
||||
REQUIRE(afterAst);
|
||||
CHECK(astToString(&afterAst.getValue()) ==
|
||||
"<Fn ___fn___4 <List <Symbol x>> to <Fn ___fn___3 <List <Symbol y>> to <Symbol x>> <Symbol z>>"
|
||||
);
|
||||
"<Fn ___fn___4 <List <Symbol x>> to <Fn ___fn___3 <List <Symbol y>> "
|
||||
"to <Symbol x>> <Symbol z>>");
|
||||
|
||||
ast = reader::read("(fn (x) (def a b) (def b c))");
|
||||
ast = reader::read("(fn (x) (def a b) (def b c))");
|
||||
afterAst = reader::analyze(*ctx, ast.getValue());
|
||||
REQUIRE(afterAst);
|
||||
CHECK(astToString(&afterAst.getValue()) ==
|
||||
"<Fn ___fn___5 <List <Symbol x>> to <Def a -> <Symbol b>> <Def b -> <Symbol c>>>");
|
||||
"<Fn ___fn___5 <List <Symbol x>> to <Def a -> <Symbol b>> <Def b -> "
|
||||
"<Symbol c>>>");
|
||||
}
|
||||
|
||||
TEST_CASE("Complex semantic analysis", "[semantic]") {
|
||||
auto ctx = makeSereneContext();
|
||||
auto ns = makeNamespace(*ctx, "user", llvm::None);
|
||||
auto ns = makeNamespace(*ctx, "user", llvm::None);
|
||||
auto ast =
|
||||
reader::read("(def a (fn (x) x))\n((def b (fn (x) (fn (y) y))))\n\n");
|
||||
auto afterAst = reader::analyze(*ctx, ast.getValue());
|
||||
REQUIRE(afterAst);
|
||||
CHECK(astToString(&afterAst.getValue()) ==
|
||||
"<Def a -> <Fn a <List <Symbol x>> to <Symbol x>>> <Call <Def b -> <Fn b <List <Symbol x>> to <Fn ___fn___1 <List <Symbol y>> to <Symbol y>>>> >");
|
||||
"<Def a -> <Fn a <List <Symbol x>> to <Symbol x>>> <Call <Def b -> "
|
||||
"<Fn b <List <Symbol x>> to <Fn ___fn___1 <List <Symbol y>> to "
|
||||
"<Symbol y>>>> >");
|
||||
|
||||
ctx = makeSereneContext();
|
||||
ns = makeNamespace(*ctx, "user", llvm::None);
|
||||
ast = reader::read("((a b))");
|
||||
ctx = makeSereneContext();
|
||||
ns = makeNamespace(*ctx, "user", llvm::None);
|
||||
ast = reader::read("((a b))");
|
||||
afterAst = reader::analyze(*ctx, ast.getValue());
|
||||
REQUIRE_FALSE(afterAst);
|
||||
auto errs = afterAst.getError();
|
||||
CHECK(errs[0]->toString() == "<Error E5: Can't resolve the symbol 'a'>");
|
||||
|
||||
ctx = makeSereneContext();
|
||||
ns = makeNamespace(*ctx, "user", llvm::None);
|
||||
ast = reader::read("(def a (fn (x) x)) (a b)");
|
||||
ctx = makeSereneContext();
|
||||
ns = makeNamespace(*ctx, "user", llvm::None);
|
||||
ast = reader::read("(def a (fn (x) x)) (a b)");
|
||||
afterAst = reader::analyze(*ctx, ast.getValue());
|
||||
REQUIRE(afterAst);
|
||||
|
||||
CHECK(astToString(&afterAst.getValue()) ==
|
||||
"<Def a -> <Fn a <List <Symbol x>> to <Symbol x>>> <Call <Fn a <List <Symbol x>> to <Symbol x>> <Symbol b>>");
|
||||
"<Def a -> <Fn a <List <Symbol x>> to <Symbol x>>> <Call <Fn a <List "
|
||||
"<Symbol x>> to <Symbol x>> <Symbol b>>");
|
||||
}
|
||||
} // namespace exprs
|
||||
} // namespace serene
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- C++ -*-
|
||||
* Serene programming language.
|
||||
*
|
||||
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
* Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -22,8 +22,9 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "../test_helpers.cpp.inc"
|
||||
#include "serene/exprs/number.h"
|
||||
|
||||
#include "../test_helpers.cpp.inc"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
namespace serene {
|
||||
|
@ -40,8 +41,8 @@ TEST_CASE("Number Expression", "[expression]") {
|
|||
|
||||
CHECK(num1->toString() == "<Number 3>");
|
||||
CHECK(num2->toString() == "<Number 3.4>");
|
||||
CHECK(num3->toString() == "<Number 3>");
|
||||
CHECK(num4->toString() == "<Number -3>");
|
||||
CHECK(num3->toString() == "<Number 3>");
|
||||
CHECK(num4->toString() == "<Number -3>");
|
||||
};
|
||||
|
||||
} // namespace exprs
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- C++ -*-
|
||||
* Serene programming language.
|
||||
*
|
||||
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
* Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -22,10 +22,11 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "../test_helpers.cpp.inc"
|
||||
#include "serene/exprs/expression.h"
|
||||
#include "serene/exprs/symbol.h"
|
||||
|
||||
#include "../test_helpers.cpp.inc"
|
||||
|
||||
namespace serene {
|
||||
namespace exprs {
|
||||
|
||||
|
@ -34,7 +35,7 @@ TEST_CASE("Public Symbol API", "[expression]") {
|
|||
auto sym = make<Symbol>(*range.get(), "example");
|
||||
|
||||
REQUIRE(sym->getType() == ExprType::Symbol);
|
||||
CHECK(sym->toString() == "<Symbol example>");
|
||||
CHECK(sym->toString() == "<Symbol example>");
|
||||
};
|
||||
} // namespace exprs
|
||||
} // namespace serene
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- C++ -*-
|
||||
* Serene programming language.
|
||||
*
|
||||
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
* Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -22,19 +22,20 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "./test_helpers.cpp.inc"
|
||||
#include "serene/context.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
#include "serene/namespace.h"
|
||||
#include "serene/reader/reader.h"
|
||||
|
||||
#include "./test_helpers.cpp.inc"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
namespace serene {
|
||||
|
||||
TEST_CASE("Namespace tests", "[namespace]") {
|
||||
auto ctx = makeSereneContext();
|
||||
auto userNs =
|
||||
makeNamespace(*ctx, "user", llvm::Optional<llvm::StringRef>("/some/file"));
|
||||
auto ctx = makeSereneContext();
|
||||
auto userNs = makeNamespace(*ctx, "user",
|
||||
llvm::Optional<llvm::StringRef>("/some/file"));
|
||||
|
||||
auto maybeAst = reader::read("(x 1) (def b a)");
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- C++ -*-
|
||||
* Serene programming language.
|
||||
*
|
||||
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
* Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -22,8 +22,9 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "../test_helpers.cpp.inc"
|
||||
#include "serene/reader/reader.h"
|
||||
|
||||
#include "../test_helpers.cpp.inc"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
namespace serene {
|
||||
|
@ -38,7 +39,7 @@ TEST_CASE("Read numbers", "[reader]") {
|
|||
|
||||
auto ast = std::move(maybeAst).getValue();
|
||||
REQUIRE_FALSE(ast.empty());
|
||||
CHECK(ast.front()->toString() == "<Number 3>");
|
||||
CHECK(ast.front()->toString() == "<Number 3>");
|
||||
|
||||
maybeAst = reader::read("-34");
|
||||
|
||||
|
@ -48,7 +49,7 @@ TEST_CASE("Read numbers", "[reader]") {
|
|||
|
||||
ast = std::move(maybeAst.getValue());
|
||||
REQUIRE_FALSE(ast.empty());
|
||||
CHECK(ast.front()->toString() == "<Number -34>");
|
||||
CHECK(ast.front()->toString() == "<Number -34>");
|
||||
|
||||
maybeAst = reader::read("-3.5434");
|
||||
|
||||
|
@ -58,7 +59,7 @@ TEST_CASE("Read numbers", "[reader]") {
|
|||
|
||||
ast = std::move(maybeAst.getValue());
|
||||
REQUIRE_FALSE(ast.empty());
|
||||
CHECK(ast.front()->toString() == "<Number -3.5434>");
|
||||
CHECK(ast.front()->toString() == "<Number -3.5434>");
|
||||
|
||||
maybeAst = reader::read("444323 2123 123123");
|
||||
|
||||
|
@ -68,8 +69,8 @@ TEST_CASE("Read numbers", "[reader]") {
|
|||
|
||||
ast = std::move(maybeAst.getValue());
|
||||
REQUIRE(ast.size() == 3);
|
||||
CHECK(ast.front()->toString() == "<Number 444323>");
|
||||
CHECK(ast[1]->toString() == "<Number 2123>" );
|
||||
CHECK(ast.front()->toString() == "<Number 444323>");
|
||||
CHECK(ast[1]->toString() == "<Number 2123>");
|
||||
CHECK(ast[2]->toString() == "<Number 123123>");
|
||||
};
|
||||
TEST_CASE("Read Lists and Symbols", "[reader]") {
|
||||
|
@ -81,7 +82,7 @@ TEST_CASE("Read Lists and Symbols", "[reader]") {
|
|||
|
||||
auto ast = std::move(maybeAst.getValue());
|
||||
REQUIRE_FALSE(ast.empty());
|
||||
CHECK(ast.front()->toString() == "<List <Symbol x> <Number 1>>");
|
||||
CHECK(ast.front()->toString() == "<List <Symbol x> <Number 1>>");
|
||||
|
||||
maybeAst = reader::read("(x (y (z)))");
|
||||
|
||||
|
@ -91,7 +92,8 @@ TEST_CASE("Read Lists and Symbols", "[reader]") {
|
|||
|
||||
ast = std::move(maybeAst.getValue());
|
||||
REQUIRE_FALSE(ast.empty());
|
||||
CHECK(ast.front()->toString() == "<List <Symbol x> <List <Symbol y> <List <Symbol z>>>>");
|
||||
CHECK(ast.front()->toString() ==
|
||||
"<List <Symbol x> <List <Symbol y> <List <Symbol z>>>>");
|
||||
|
||||
maybeAst = reader::read("(x \n y)");
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- C++ -*-
|
||||
* Serene programming language.
|
||||
*
|
||||
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
* Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -25,23 +25,23 @@
|
|||
#ifndef TEST_HEALPERS_H
|
||||
#define TEST_HEALPERS_H
|
||||
|
||||
#include "catch2/catch.hpp"
|
||||
#include "serene/reader/location.h"
|
||||
|
||||
namespace serene {
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
namespace serene {
|
||||
|
||||
reader::LocationRange *dummyLocation() {
|
||||
reader::Location start;
|
||||
reader::Location end;
|
||||
|
||||
start.line = 2;
|
||||
start.col = 20;
|
||||
start.pos = 40;
|
||||
start.col = 20;
|
||||
start.pos = 40;
|
||||
|
||||
end.line = 3;
|
||||
end.col = 30;
|
||||
end.pos = 80;
|
||||
end.col = 30;
|
||||
end.pos = 80;
|
||||
|
||||
return new reader::LocationRange(start, end);
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- C++ -*-
|
||||
* Serene programming language.
|
||||
*
|
||||
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
* Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -22,8 +22,9 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "./test_helpers.cpp.inc"
|
||||
#include "serene/traits.h"
|
||||
|
||||
#include "./test_helpers.cpp.inc"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
namespace serene {
|
||||
|
@ -44,9 +45,13 @@ public:
|
|||
std::string Analyze() { return this->Object().Analyze(); }
|
||||
};
|
||||
|
||||
template <typename T> std::string Print(Printable<T> &t) { return t.Print(); }
|
||||
template <typename T>
|
||||
std::string Print(Printable<T> &t) {
|
||||
return t.Print();
|
||||
}
|
||||
|
||||
template <typename T> std::string Analyze(Analyzable<T> &t) {
|
||||
template <typename T>
|
||||
std::string Analyze(Analyzable<T> &t) {
|
||||
return t.Analyze();
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*- C++ -*-
|
||||
* Serene programming language.
|
||||
*
|
||||
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
* Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -21,9 +21,10 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "./test_helpers.cpp.inc"
|
||||
#include "serene/utils.h"
|
||||
|
||||
#include "./test_helpers.cpp.inc"
|
||||
|
||||
namespace serene {
|
||||
TEST_CASE("Result Type", "[utils]") {
|
||||
auto r = Result<int>::success(4);
|
||||
|
|
Loading…
Reference in New Issue