Skip to content

Commit

Permalink
Create failing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Roel van Bakel committed Aug 30, 2023
1 parent 4f1ad21 commit 9cddac9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src-test/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import {nameBasedConceptDeducerFor} from "../src/m3/functions.ts"
import {libraryLanguage} from "./m3/library-language.ts"


export enum BookType {
Normal,
Special,
}

export type BaseNode = Node & {
concept: string
}
Expand All @@ -14,6 +19,7 @@ export type Book = BaseNode & {
title: string
pages: number
author: Writer
type?: BookType
}

export type Library = BaseNode & {
Expand Down Expand Up @@ -62,7 +68,8 @@ const explorerBook: Book = {
concept: "Book",
title: "Explorer Book",
author: jackLondon,
pages: 1337
pages: 1337,
type: BookType.Special
}

const bobLibrary: Library = {
Expand Down
11 changes: 11 additions & 0 deletions src-test/m3/ecore/library.ecore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
<details key="name" value="author"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" lowerBound="0"
eType="#//BookType">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="type"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Library">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" unique="false" lowerBound="1"
Expand All @@ -56,6 +63,10 @@
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="BookType">
<eLiterals name="Normal"/>
<eLiterals name="Special"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="GuideBookWriter" eSuperTypes="#//Writer">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="countries" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
Expand Down
9 changes: 8 additions & 1 deletion src-test/m3/library-language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const book = factory.concept("Book", false)
const writer = factory.concept("Writer", false)
const guideBookWriter = factory.concept("GuideBookWriter", false, writer)
const specialistBookWriter = factory.concept("SpecialistBookWriter", false, writer)
const bookType = factory.enumeration("BookType")
bookType.havingLiterals(
factory.enumerationLiteral(bookType, "normal"),
factory.enumerationLiteral(bookType, "special"),
)

const library_name = factory.property(library, "name").ofType(stringDatatype).havingKey("library_Library_name")
const library_books = factory.containment(library, "books").ofType(book).isMultiple()
Expand All @@ -21,7 +26,8 @@ library.havingFeatures(library_name, library_books)
const book_title = factory.property(book, "title").ofType(stringDatatype)
const book_pages = factory.property(book, "pages").ofType(intDatatype)
const book_author = factory.reference(book, "author").ofType(writer)
book.havingFeatures(book_title, book_pages, book_author)
const book_type = factory.property(book, "type").ofType(bookType).isOptional()
book.havingFeatures(book_title, book_pages, book_author, book_type)

const writer_name = factory.property(writer, "name").ofType(stringDatatype).havingKey("library_Writer_name")
writer.havingFeatures(writer_name)
Expand All @@ -36,6 +42,7 @@ specialistBookWriter.havingFeatures(specialistBookWriter_subject)

libraryLanguage.havingEntities(
book,
bookType,
library,
writer,
guideBookWriter,
Expand Down

0 comments on commit 9cddac9

Please sign in to comment.