-
Notifications
You must be signed in to change notification settings - Fork 30
Bugs: identitymap for datatype attributes #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
h-man2
wants to merge
5
commits into
master
Choose a base branch
from
bugs/identitymap_for_datatype_attributes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a2c937d
fix: Attributes in Datatype stored in IdentityMap
h-man2 fb1105d
style: fixed IntelliJ warnings
h-man2 58b1d03
fix: wrong calculation of before
h-man2 8b29480
test: added regression test for IdentityMap error
h-man2 8eddd83
Merge remote-tracking branch 'origin/bugs/identitymap_for_datatype_at…
h-man2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
use-gui/src/it/resources/testfiles/shell/imports/t133_import_date.use
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| model Date | ||
|
|
||
| dataType Date | ||
| operations | ||
| Date(day: Integer, month : Integer, year : Integer) | ||
| pre: day >= 1 and day <= 31 | ||
| pre: month >= 1 and month <= 12 | ||
|
|
||
| getMonths() : Sequence(Tuple(days : Integer, name : String)) = Sequence{ | ||
| Tuple{name='January', days=31}, | ||
| Tuple{name='February', days=if self.isLeapYear() then 29 else 28 endif}, | ||
| Tuple{name='March', days=31}, | ||
| Tuple{name='April', days=30}, | ||
| Tuple{name='May', days=31}, | ||
| Tuple{name='June', days=30}, | ||
| Tuple{name='July', days=31}, | ||
| Tuple{name='August', days=31}, | ||
| Tuple{name='September', days=30}, | ||
| Tuple{name='October', days=31}, | ||
| Tuple{name='November', days=30}, | ||
| Tuple{name='December', days=31} | ||
| } | ||
|
|
||
| before(other:Date):Boolean = | ||
| self.year < other.year or | ||
| (self.year = other.year and self.month < other.month) or | ||
| (self.year = other.year and self.month = other.month and self.day < other.day) | ||
|
|
||
| equals(other:Date):Boolean = | ||
| self.day = other.day and | ||
| self.month = other.month and | ||
| self.year = other.year | ||
|
|
||
| isLeapYear() : Boolean = | ||
| self.year.mod(400) = 0 or (self.year.mod(4) = 0 and self.year.mod(100) <> 0) | ||
|
|
||
| add(days : Integer) : Date = | ||
| Sequence{1..days}->iterate(d; result : Date = | ||
| Date(self.day, self.month, self.year) | | ||
| if result.day + 1 > self.getMonths()->at(result.month).days then | ||
| if (result.month = 12) then | ||
| Date(1, 1, result.year + 1) | ||
| else | ||
| Date(1, result.month + 1, result.year) | ||
| endif | ||
| else | ||
| Date(result.day + 1, result.month, result.year) | ||
| endif | ||
| ) | ||
|
|
||
| getEasterSunday() : Date = | ||
| // Following Gauss algorithm to calculate eastern | ||
|
|
||
| // See: https://de.wikipedia.org/wiki/Gau%C3%9Fsche_Osterformel | ||
|
|
||
| let k:Integer = (self.year / 100).floor() in | ||
| let m:Integer = 15 + ((3 * k) / 4).floor() - ((8 * k + 13) / 25).floor() in | ||
| let s:Integer = 2 - ((3 * k + 3) / 4).floor() in | ||
| let a:Integer = self.year.mod(19) in | ||
| let d:Integer = (19 * a + m).mod(30) in | ||
| let r:Integer = ((d + (a / 11).floor()) / 29).floor() in | ||
| let og:Integer = 21 + d - r in | ||
| let sz:Integer = 7 - (self.year + (self.year / 4).floor() + s).mod(7) in | ||
| let oe:Integer = 7 - (og - sz).mod(7) in | ||
| let os:Integer = og + oe in | ||
| Date(1, 3, self.year).add(os - 1) | ||
| end | ||
|
|
||
13 changes: 13 additions & 0 deletions
13
use-gui/src/it/resources/testfiles/shell/imports/t133_import_datetime.use
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import Date from "t133_import_date.use" | ||
| import Time from "t133_import_time.use" | ||
|
|
||
| model DateTime | ||
|
|
||
| dataType DateTime | ||
| operations | ||
| DateTime(date:Date, time:Time) | ||
|
|
||
| before(other:DateTime):Boolean = | ||
| self.date.before(other.date) or | ||
| (self.date.equals(other.date) and self.time.before(other.time)) | ||
| end |
14 changes: 14 additions & 0 deletions
14
use-gui/src/it/resources/testfiles/shell/imports/t133_import_time.use
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| model Time | ||
|
|
||
| dataType Time | ||
| operations | ||
| Time(hour: Integer, minute: Integer, second: Integer) | ||
| pre: hour >= 0 and hour < 24 | ||
| pre: minute >= 0 and minute < 60 | ||
| pre: second >= 0 and second < 60 | ||
|
|
||
| before(other: Time) : Boolean = | ||
| self.hour < other.hour or | ||
| (self.hour = other.hour and self.minute < other.minute) or | ||
| (self.hour = other.hour and self.minute = other.minute and self.second < other.second) | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| -- Script generated by USE 7.5.0 | ||
|
|
||
| !new Bootstyp('btTretboot') | ||
| !new Bootstyp('btSegelboot') | ||
| !new Bootstyp('btMotorboot') | ||
| !new Boot('bSchwalbe') | ||
| !new Boot('bMoewe') | ||
| !new Person('pAda') | ||
| !new Person('pBob') | ||
| !new Person('pCyd') | ||
| !new Person('pDan') | ||
| !new Person('pEve') | ||
| !btTretboot.bezeichnung := 'Tretboot' | ||
| !btSegelboot.bezeichnung := 'Segelboot' | ||
| !btMotorboot.bezeichnung := 'Motorboot' | ||
| !pAda.name := 'Ada' | ||
| !pBob.name := 'Bob' | ||
| !pCyd.name := 'Cyd' | ||
| !pDan.name := 'Dan' | ||
| !pEve.name := 'Eve' | ||
| !bSchwalbe.bezeichnung := 'Schwalbe' | ||
| !bSchwalbe.kapazitaet := 2 | ||
| !bMoewe.bezeichnung := 'Möwe' | ||
| !bMoewe.kapazitaet := 4 | ||
| !insert (bSchwalbe,btTretboot) into A_BootBootstyp | ||
| !insert (bMoewe,btMotorboot) into A_BootBootstyp | ||
| !new Vermietung('v1') | ||
| !v1.start := DateTime(Date(17, 4, 2026), Time(11, 0, 0)) | ||
| !v1.ende := DateTime(Date(17, 4, 2026), Time(13, 0, 0)) | ||
| !insert (v1,bSchwalbe) into A_Vermietung_Boot | ||
| !insert (v1,pAda) into A_Vermietung_Hauptmieter | ||
| !insert (v1,pBob) into A_Vermietung_Mitfahrer | ||
| !insert (v1,pAda) into A_Vermietung_Mitfahrer | ||
| ?v1.start.before(v1.ende) | ||
| *-> true : Boolean | ||
| check | ||
| *checking structure... | ||
| *checking invariants... | ||
| *checking invariant (1) `Vermietung::businessHours': OK. | ||
| *checking invariant (2) `Vermietung::kapazitaetNichtUeberschritten': OK. | ||
| *checking invariant (3) `Vermietung::validDuration': OK. | ||
| *checked 3 invariants, 0 failures. | ||
| exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| -- Test indirect imports | ||
|
|
||
| import { Date } from "imports/t133_import_date.use" | ||
| import { Time } from "imports/t133_import_time.use" | ||
| import { DateTime } from "imports/t133_import_datetime.use" | ||
|
|
||
| model Bootsverleih | ||
|
|
||
| class Boot | ||
| attributes | ||
| bezeichnung : String | ||
| kapazitaet : Integer | ||
| end | ||
|
|
||
| class Bootstyp | ||
| attributes | ||
| bezeichnung : String | ||
| end | ||
|
|
||
| class Vermietung | ||
| attributes | ||
| start : DateTime | ||
| ende : DateTime | ||
| constraints | ||
| inv validDuration: | ||
| self.start.before(self.ende) | ||
| inv businessHours: | ||
| self.start.time.hour >= 9 and | ||
| self.start.time.hour < 19 and | ||
| self.ende.time.hour < 19 and | ||
| self.ende.time.hour >= 9 | ||
| inv kapazitaetNichtUeberschritten: | ||
| self.mitfaherer->size() <= self.boot.kapazitaet | ||
| end | ||
|
|
||
| class Person | ||
| attributes | ||
| name : String | ||
| telefonNr : String | ||
| end | ||
|
|
||
| association A_BootBootstyp between | ||
| Boot[*] | ||
| Bootstyp[1] | ||
| end | ||
|
|
||
| association A_Vermietung_Boot between | ||
| Vermietung[*] | ||
| Boot[1] | ||
| end | ||
|
|
||
| association A_Vermietung_Hauptmieter between | ||
| Vermietung[*] role bootsmieten | ||
| Person[1] role hauptmieter | ||
| end | ||
|
|
||
| association A_Vermietung_Mitfahrer between | ||
| Vermietung[*] role mitfahrten | ||
| Person[0..*] role mitfaherer | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.