Fix the license header

This commit is contained in:
Sameer Rahmani 2022-02-08 17:56:15 +00:00
parent 7dc587ecbc
commit f663ba0c25
16 changed files with 118 additions and 96 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,9 +22,10 @@
* 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 {
@ -35,7 +36,8 @@ TEST_CASE("Context tests", "[context]") {
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 userNs = makeNamespace(*ctx, "user",
llvm::Optional<llvm::StringRef>("/some/file"));
auto isSet = ctx->setCurrentNS("user");

View File

@ -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");

View File

@ -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

View File

@ -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 {

View File

@ -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 {
@ -130,8 +131,8 @@ TEST_CASE("List semantic analysis for 'fn'", "[semantic]") {
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)");
afterAst = reader::analyze(*ctx, ast.getValue());
@ -143,14 +144,15 @@ TEST_CASE("List semantic analysis for 'fn'", "[semantic]") {
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))");
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]") {
@ -161,7 +163,9 @@ TEST_CASE("Complex semantic analysis", "[semantic]") {
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);
@ -178,7 +182,8 @@ TEST_CASE("Complex semantic analysis", "[semantic]") {
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

View File

@ -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 {

View File

@ -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 {

View File

@ -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 userNs = makeNamespace(*ctx, "user",
llvm::Optional<llvm::StringRef>("/some/file"));
auto maybeAst = reader::read("(x 1) (def b a)");

View File

@ -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 {
@ -69,7 +70,7 @@ 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[1]->toString() == "<Number 2123>");
CHECK(ast[2]->toString() == "<Number 123123>");
};
TEST_CASE("Read Lists and Symbols", "[reader]") {
@ -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)");

View File

@ -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,11 +25,11 @@
#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;

View File

@ -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();
};

View File

@ -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);