Skip to content
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

Evaluation of lobster-regex tool #184

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
83 changes: 83 additions & 0 deletions lobster/tools/regex/requirements.trlc
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package regex_req
import req

req.Tool_Definition Valid_Config_Path {
title = '''Valid config path given'''
description = '''
Valid config path means that the tool was called with
an existing [[Config_File_Path]].
'''
}

req.Tool_Definition No_Config_Path {
title = '''No config path given'''
description = '''
No config path means that the tool was called with nothing specified
as the command line.
'''
}

req.Tool_Definition Invalid_Config_Path {
title = '''Invalid path given'''
description = '''
Invalid config path means that the tool was called with
a non-existent [[Config_File_Path]].
'''
}

req.Tool_Definition Valid_Config_File {
title = '''Valid config file given'''
description = '''
Valid config file means that the tool was called with
a [[Config_File]].
'''
}

req.Tool_Definition Invalid_Config_File {
title = '''Invalid config file given'''
description = '''
Invalid config file means that the tool was called with a file
which is not [[Config_File]].
'''
}


req.Tool_Config_Parameter Config_File {
description = '''
This Yarn file consists of the configuration of the tool.
The file should consist of the following keys: test_case_names_regex, requirements_regex, output
'''
}

req.Tool_Config_Parameter Config_File_Path {
description = '''
This parameter specifies the path to [[Config_File]] as a command line .
'''
}



req.System_Requirement Valid_Input_Config {
description = '''
If [[Valid_Config_Path]] and [[Valid_Config_File]] are specified, the output file/s containing the extracted tests
will be written with user-specific markers to the file specified in [[Config_File]].
'''
}

req.System_Requirement_Else No_Input_Config {
description = '''
Else if [[No_Config_Path]], the tool shall exit with return code 1.
'''
}

req.System_Requirement_Else Invalid_Input_Config_Path {
description = '''
Else if [[Invalid_Config_Path]], the tool shall exit with return code 1.
'''
}

req.System_Requirement_Else Invalid_Input_Config_File {
description = '''
Else if [[Invalid_Config_File]], the tool shall exit with return code 1.
'''
}
23 changes: 23 additions & 0 deletions lobster/tools/requirements.rsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
package req

type Tool_Definition {
title '''
Title of the definition.
''' String
description '''
A definition describes what a particular entity is.
''' String
}

type Tool_Config_Parameter {
description '''
A tool configuration parameter describes the exact way in which the
parameters shall be given for the tool from the user's point of view.
''' String
}

type System_Requirement {
description '''
The content of the requirement.
Expand All @@ -14,3 +30,10 @@ type Software_Requirement {
A software requirement describes the behaviour of a lobster tool.
''' String
}

type System_Requirement_Else {
description '''
A tool requirement else describes the behavior of a Lobster tool in which the specific conditions
can be applied by the user.
''' String
}
72 changes: 72 additions & 0 deletions tests-system/lobster-regex/data/test_case.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* A simple Scala program demonstrating various features like
* case classes, objects, methods, and documentation comments.
*/

// Define a case class to represent a Person
case class Person(name: String, age: Int)

/**
* An object to hold utility methods for greeting and age validation.
*/
object Utilities {

/**
* Generates a greeting message for a person.
*
* @requirement CB-#0815 CB-#0816
*
* @param person The person to greet.
* @return A greeting string.
*/
def greet(person: Person): String = {
s"Hello, ${person.name}! You are ${person.age} years old."
}

/**
* Checks if a person is considered an adult.
*
* @requirement CB-#0815, CB-#0816,
* CB-#0817
* @requirement CB-#0818 CB-#0819
* CB-#0820
*
* @param person The person to check.
* @return True if the person is an adult (18 or older), otherwise false.
*/
def isAdult(person: Person): Boolean = {
person.age >= 18
}
}

/**
* The main object to run the program.
*/
object Main {

/**
* The entry point of the application.
*
* @requiredby FOO0::BAR0, FOO1::BAR1,
* FOO2::BAR2
* @requiredby FOO3::BAR3 FOO4::BAR4,
* FOO5::BAR5
* @requiredby FOO6::BAR6 FOO7::BAR7
* FOO8::BAR8
*
* @param args Command-line arguments (not used in this program).
*/
def main(args: Array[String]): Unit = {
val person = Person("Alice", 25)

// Generate a greeting
println(Utilities.greet(person))

// Check if the person is an adult
if (Utilities.isAdult(person)) {
println(s"${person.name} is an adult.")
} else {
println(s"${person.name} is not an adult.")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"data": [
{
"tag": "scala test_case.scala:greet:14",
"location": {
"kind": "file",
"file": "test_case.scala",
"line": 14,
"column": null
},
"name": "test_case.scala:greet:14",
"messages": [],
"just_up": [],
"just_down": [],
"just_global": [],
"refs": [
"req 0815",
"req 0816"
],
"framework": "regex",
"kind": "Function",
"status": null
},
{
"tag": "scala test_case.scala:isAdult:26",
"location": {
"kind": "file",
"file": "test_case.scala",
"line": 26,
"column": null
},
"name": "test_case.scala:isAdult:26",
"messages": [],
"just_up": [],
"just_down": [],
"just_global": [],
"refs": [
"req 0815",
"req 0816",
"req 0817",
"req 0818",
"req 0819",
"req 0820"
],
"framework": "regex",
"kind": "Function",
"status": null
},
{
"tag": "scala test_case.scala:main:47",
"location": {
"kind": "file",
"file": "test_case.scala",
"line": 47,
"column": null
},
"name": "test_case.scala:main:47",
"messages": [],
"just_up": [],
"just_down": [],
"just_global": [],
"refs": [
"req FOO0::BAR0",
"req FOO1::BAR1",
"req FOO2::BAR2",
"req FOO3::BAR3",
"req FOO4::BAR4",
"req FOO5::BAR5",
"req FOO6::BAR6",
"req FOO7::BAR7",
"req FOO8::BAR8"
],
"framework": "regex",
"kind": "Function",
"status": null
}
],
"generator": "lobster-regex",
"schema": "lobster-act-trace",
"version": 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Written 3 lobster items to "output.lobster".
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--config=default_file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
files:
- data/test_case.scala
object-name-regex:
- (\\w+[\\s\\t\\n]*)*def[\\s\\t\\n]*((\\w+)|(`(\\w+)`))[\\s\\t\\n]*\\(
requirements_regex:
"@requirement":
- (CB-#\\d+)
"@requiredby":
- (\\w*::\\w+)
docstring_regex:
- /\*\*.*?\*/
direction: forward
output:
output.lobster:
markers:
- "@requirement"
- "@requiredby"
kind: "req"
Loading