File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed
src/Domain/HydraScript.Domain.BackEnd/Impl/Instructions/WithAssignment
tests/HydraScript.UnitTests/Domain/BackEnd Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,12 @@ public partial class AsString(IValue value) : Simple(value)
1818 public override IAddress ? Execute ( IExecuteParams executeParams )
1919 {
2020 var frame = executeParams . Frames . Peek ( ) ;
21- frame [ Left ! ] = JsonSerializer . Serialize (
22- value : Right . right ! . Get ( frame ) ! ,
23- AsStringJsonContext . Object ) ;
21+ var value = Right . right ! . Get ( frame ) ;
22+ frame [ Left ! ] = value is string
23+ ? value
24+ : JsonSerializer . Serialize (
25+ value : Right . right ! . Get ( frame ) ! ,
26+ AsStringJsonContext . Object ) ;
2427
2528 return Address . Next ;
2629 }
Original file line number Diff line number Diff line change 1+ using HydraScript . Domain . BackEnd ;
2+ using HydraScript . Domain . BackEnd . Impl ;
3+ using HydraScript . Domain . BackEnd . Impl . Instructions . WithAssignment ;
4+ using HydraScript . Domain . BackEnd . Impl . Values ;
5+
6+ namespace HydraScript . UnitTests . Domain . BackEnd ;
7+
8+ public class AsStringTests
9+ {
10+ [ Theory , AutoHydraScriptData ]
11+ public void Execute_String_NoQuotes ( VirtualMachine vm )
12+ {
13+ // Arrange
14+ AddressedInstructions program = [ new AsString ( new Constant ( "string" ) ) ] ;
15+ vm . ExecuteParams . Frames . Push ( new Frame ( program . Start ) ) ;
16+
17+ // Act
18+ program [ program . Start ] . Execute ( vm . ExecuteParams ) ;
19+
20+ // Assert
21+ var frame = vm . ExecuteParams . Frames . Peek ( ) ;
22+ frame [ program . Start . Name ] . Should ( ) . Be ( "string" ) ;
23+ frame [ program . Start . Name ] . Should ( ) . NotBe ( "\" string\" " ) ;
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments