From f8f19a712d9bbcd84870900bd779dfe1ca1978b0 Mon Sep 17 00:00:00 2001 From: Softonik Date: Sun, 20 Nov 2022 03:37:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA?= =?UTF-8?q?=D0=B0=20continue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- transpile/service.go | 2 +- transpile/service_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/transpile/service.go b/transpile/service.go index b608d47..c252a88 100644 --- a/transpile/service.go +++ b/transpile/service.go @@ -385,7 +385,7 @@ func handleBlockStmt(body *ast.BlockStmt) string { } func handleBranchStmt(stmt *ast.BranchStmt) string { - return "break;" + return stmt.Tok.String() + ";" } func handleCaseClause(cc *ast.CaseClause) string { diff --git a/transpile/service_test.go b/transpile/service_test.go index 2a6ebfe..e8fad3b 100644 --- a/transpile/service_test.go +++ b/transpile/service_test.go @@ -859,6 +859,32 @@ var _ = Describe("Go Translator", func() { ` Compare(source, expected) }) + It("for { continue }", func() { + source := `package test + func Setup() {} + func Loop() { + for { + if v == 0 { + continue + } + } + } + ` + expected := ` + void setup(); + void loop(); + + void setup() {} + void loop() { + while (1) { + if (v == 0) { + continue; + } + } + } + ` + Compare(source, expected) + }) }) Describe("Действия", func() { It("nil -> NULL", func() {