go-translator/pkg/service/features/app.feature

198 строки
2,8 КиБ
Gherkin

# Во имя Бога Милостивого, Милосердного!!!
# language: ru
Функциональность: Преобразование в C++
Сценарий: Пустой пакет
* Исходник:
```
package test
```
* Результат:
```
void loop() {}
void setup() {}
```
Сценарий: Пустая структура - класс
* Исходник:
```
package test
type device struct {}
```
* Результат:
```
class device {
public:
};
```
Сценарий: Структура с полем
* Исходник:
```
package test
type device struct {
a int
}
```
* Результат:
```
class device {
public:
int a;
};
```
Сценарий: Структура с полями одного типа
* Исходник:
```
package test
type device struct {
a,b int
}
```
* Результат:
```
class device {
public:
int a,b;
};
```
Сценарий: Структура с неск полями, строки - std::string
* Исходник:
```
package test
type device struct {
a,b int
c,d,e string
}
```
* Результат:
```
class device {
public:
int a,b;
std::string c,d,e;
};
```
Сценарий: Структура с методом
* Исходник:
```
package test
type device struct {
a int
}
func (d *device) doSomething() {
}
```
* Результат:
```
class device {
public:
int a;
void doSomething();
};
void device::doSomething() {
}
```
Сценарий: Структура с вызовом метода
* Исходник:
```
package test
type device struct {
a int
}
func (d *device) doSomething() {
d.doSomethingElse()
}
func (d *device) doSomethingElse() {
}
```
* Результат:
```
class device {
public:
int a;
void doSomething();
void doSomethingElse();
};
void device::doSomething() {
this->doSomethingElse();
}
void device::doSomethingElse() {
}
```
Сценарий: Структура с изменением свойства
* Исходник:
```
package test
type device struct {
x int
y int
}
func (d *device) doSomething() {
d.x = 1
d.x = d.y
}
```
* Результат:
```
class device {
public:
int x;
int y;
void doSomething();
};
void device::doSomething() {
this->x=1;
this->x=this->y;
}
```
Сценарий: Структура с вызовом метода и свойства другого объекта
* Исходник:
```
package test
type device struct {
x int
}
func (d *device) doSomething() {
dev2.doSomethingElse()
}
func (d *device) doSomethingElse() {
dev2.x = 1
d.x = dev2.x
}
```
* Результат:
```
class device {
public:
int x;
void doSomething();
void doSomethingElse();
};
void device::doSomething() {
dev2->doSomethingElse();
}
void device::doSomethingElse() {
dev2->x=1;
this->x=dev2->x;
}
```