-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #541 from jvalue/540-feature-lowercaseuppercase-op…
…erator add unary operators 'lowercase' and 'uppercase'
- Loading branch information
Showing
8 changed files
with
99 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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
15 changes: 15 additions & 0 deletions
15
libs/language-server/src/lib/ast/expressions/evaluators/lowercase-operator-evaluator.spec.ts
This file contains 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,15 @@ | ||
// SPDX-FileCopyrightText: 2024 Friedrich-Alexander-Universitat Erlangen-Nurnberg | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
import { executeDefaultTextToTextExpression } from '../test-utils'; | ||
|
||
describe('The lowercase operator', () => { | ||
it('should lowercase alphabetic characters successfully', async () => { | ||
const result = await executeDefaultTextToTextExpression( | ||
'lowercase inputValue', | ||
'Hello, World!', | ||
); | ||
|
||
expect(result).toEqual('hello, world!'); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
libs/language-server/src/lib/ast/expressions/evaluators/lowercase-operator-evaluator.ts
This file contains 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,19 @@ | ||
// SPDX-FileCopyrightText: 2024 Friedrich-Alexander-Universitat Erlangen-Nurnberg | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
// eslint-disable-next-line import/no-cycle | ||
import { DefaultUnaryOperatorEvaluator } from '../operator-evaluator'; | ||
import { STRING_TYPEGUARD } from '../typeguards'; | ||
|
||
export class LowercaseOperatorEvaluator extends DefaultUnaryOperatorEvaluator< | ||
string, | ||
string | ||
> { | ||
constructor() { | ||
super('lowercase', STRING_TYPEGUARD); | ||
} | ||
override doEvaluate(operandValue: string): string { | ||
return operandValue.toLowerCase(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
libs/language-server/src/lib/ast/expressions/evaluators/uppercase-operator-evaluator.spec.ts
This file contains 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,15 @@ | ||
// SPDX-FileCopyrightText: 2024 Friedrich-Alexander-Universitat Erlangen-Nurnberg | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
import { executeDefaultTextToTextExpression } from '../test-utils'; | ||
|
||
describe('The uppercase operator', () => { | ||
it('should uppercase alphabetic characters successfully', async () => { | ||
const result = await executeDefaultTextToTextExpression( | ||
'uppercase inputValue', | ||
'Hello, World!', | ||
); | ||
|
||
expect(result).toEqual('HELLO, WORLD!'); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
libs/language-server/src/lib/ast/expressions/evaluators/uppercase-operator-evaluator.ts
This file contains 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,19 @@ | ||
// SPDX-FileCopyrightText: 2024 Friedrich-Alexander-Universitat Erlangen-Nurnberg | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
// eslint-disable-next-line import/no-cycle | ||
import { DefaultUnaryOperatorEvaluator } from '../operator-evaluator'; | ||
import { STRING_TYPEGUARD } from '../typeguards'; | ||
|
||
export class UppercaseOperatorEvaluator extends DefaultUnaryOperatorEvaluator< | ||
string, | ||
string | ||
> { | ||
constructor() { | ||
super('uppercase', STRING_TYPEGUARD); | ||
} | ||
override doEvaluate(operandValue: string): string { | ||
return operandValue.toUpperCase(); | ||
} | ||
} |
This file contains 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
18 changes: 18 additions & 0 deletions
18
.../language-server/src/lib/ast/expressions/type-computers/string-transform-type-computer.ts
This file contains 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,18 @@ | ||
// SPDX-FileCopyrightText: 2024 Friedrich-Alexander-Universitat Erlangen-Nurnberg | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
import { type ValueType } from '../../wrappers/value-type'; | ||
// eslint-disable-next-line import/no-cycle | ||
import { PrimitiveValuetypes } from '../../wrappers/value-type/primitive/primitive-value-types'; | ||
import { DefaultUnaryOperatorTypeComputer } from '../operator-type-computer'; | ||
|
||
export class StringTransformTypeComputer extends DefaultUnaryOperatorTypeComputer { | ||
constructor() { | ||
super(PrimitiveValuetypes.Text); | ||
} | ||
|
||
override doComputeType(): ValueType { | ||
return PrimitiveValuetypes.Text; | ||
} | ||
} |