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
language-support/scala: add support for specifying dependency roots explicitly #1210
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cfa6d8c
language-support/scala: add support for specifying roots explicitly
jberthold-da f896bce
scala codegen rootfilter: move filtering to envIFace handling
jberthold-da 421eadd
Merge commit 'cebefd4bd97ef7abb23ced0f6360bc96a6588b49' into EXPERIME…
S11001001 59c2c1d
doc for --root option
S11001001 7bea629
scalafmt
S11001001 28708c7
test filterTemplatesBy
S11001001 96291db
Merge commit '8ed703e14de3952c672eb167182e6b404a45447a' into EXPERIME…
S11001001 24800eb
release note for --root Scala codegen option
S11001001 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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
53 changes: 53 additions & 0 deletions
53
language-support/scala/codegen/src/test/scala/com/digitalasset/codegen/CodeGenSpec.scala
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,53 @@ | ||
// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.digitalasset | ||
package codegen | ||
|
||
import daml.lf.data.ImmArray.ImmArraySeq | ||
import daml.lf.data.Ref.Identifier | ||
import daml.lf.iface._ | ||
import daml.lf.value.ValueGenerators.idGen | ||
|
||
import org.scalatest.{WordSpec, Matchers} | ||
import org.scalatest.prop.GeneratorDrivenPropertyChecks | ||
|
||
class CodeGenSpec extends WordSpec with Matchers with GeneratorDrivenPropertyChecks { | ||
import CodeGen.filterTemplatesBy | ||
import CodeGenSpec._ | ||
|
||
"filterTemplatesBy" should { | ||
"be identity given empty regexes" in forAll(trivialEnvInterfaceGen) { ei => | ||
filterTemplatesBy(Seq.empty)(ei) should ===(ei) | ||
} | ||
|
||
"delete all templates given impossible regex" in forAll(trivialEnvInterfaceGen) { ei => | ||
val noTemplates = ei copy (ei.typeDecls transform { | ||
case (_, tmpl @ InterfaceType.Template(_, _)) => InterfaceType.Normal(tmpl.`type`) | ||
case (_, v) => v | ||
}) | ||
filterTemplatesBy(Seq("(?!a)a".r))(ei) should ===(noTemplates) | ||
} | ||
|
||
"match the union of regexes, not intersection" in forAll(trivialEnvInterfaceGen) { ei => | ||
filterTemplatesBy(Seq("(?s).*".r, "(?!a)a".r))(ei) should ===(ei) | ||
} | ||
} | ||
} | ||
|
||
object CodeGenSpec { | ||
import org.scalacheck.{Arbitrary, Gen} | ||
import Arbitrary.arbitrary | ||
|
||
val trivialEnvInterfaceGen: Gen[EnvironmentInterface] = { | ||
val fooRec = Record(ImmArraySeq.empty) | ||
val fooTmpl = InterfaceType.Template(fooRec, DefTemplate(Map.empty)) | ||
val fooNorm = InterfaceType.Normal(DefDataType(ImmArraySeq.empty, fooRec)) | ||
implicit val idArb: Arbitrary[Identifier] = Arbitrary(idGen) | ||
arbitrary[Map[Identifier, Boolean]] map { ids => | ||
EnvironmentInterface(ids transform { (_, isTemplate) => | ||
if (isTemplate) fooTmpl else fooNorm | ||
}) | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is also going to affect java codegen... and the SDK doc, that does not mention
root
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leo-da We can remove the option from the driver if you prefer but I do think it is useful to have in all codegen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jberthold-da that is fine, I was just pointing the things that we will need to address when this PR lands in master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leo-da so should I take the option out of the CLI/config, or just declare it as unsupported for java?
I do think it is a very useful option.